Results 1 to 6 of 6

Thread: How to gracefully exit EXCEL

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Location
    Irving, TX
    Posts
    1

    How to gracefully exit EXCEL

    Hi, I have a program that will parse the data from a textfile to a readable format in MS excel using vb6. Initially, it will open an excel application and create new worksheet (the program runs okay). However, if I close the excel application and process new textfile it won't open new excel application and "Permission Denied" is displayed.

    The remedy for me to run the program again is to go to Window task manager and end the process of EXCEL.EXE.

    Please help.

    rasec

  2. #2
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,713

    Re: How to gracefully exit EXCEL

    Welcome to the Forums.

    Your going to have to post some of your code for opening the excel file in order to see whats going on.

    Moved
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,471

    Re: How to gracefully exit EXCEL

    Quote Originally Posted by rasec
    Hi, I have a program that will parse the data from a textfile to a readable format in MS excel using vb6. Initially, it will open an excel application and create new worksheet (the program runs okay). However, if I close the excel application and process new textfile it won't open new excel application and "Permission Denied" is displayed.

    The remedy for me to run the program again is to go to Window task manager and end the process of EXCEL.EXE.

    Please help.

    rasec
    Here's a handy link:

    www.xtremevbtalk.com/t135815.html

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,500

    Re: How to gracefully exit EXCEL

    Noooo..... that tells you how to force it to close, rather than close it properly - just like using brick walls to stop a car because the brakes dont work properly!


    See the Excel tutorial link in my signature, it's much better in my opinion

  5. #5
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,471

    Re: How to gracefully exit EXCEL

    Quote Originally Posted by si_the_geek
    Noooo..... that tells you how to force it to close, rather than close it properly - just like using brick walls to stop a car because the brakes dont work properly!


    See the Excel tutorial link in my signature, it's much better in my opinion
    I like your link and I'm going to save it, but I just glanced at it. Can you point out what your referring too? The one I posted sure looked like Part B(4) - Close the workbook (but don't save):

    Thanks!

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,500

    Re: How to gracefully exit EXCEL

    Post 11 of the tutorial is the one with the answers to this particular issue, and post 5 is the one that contains the proper examples of closing - but that is very rarely where the issue occurs.


    What you saw in the example at the "other place" is actually a badly coded version of Part B(3) - using brackets when they should not be used (only when using Call, or returning a value from a function), not closing referenced objects (oRng1 etc).

    The really bad (maybe even evil) part however is the last post there - it tells you how to "kill" Excel if your program doesn't work properly... definitely not the right thing to do!

    There is a good part tho - the module to find invalid references (post #6).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width