Results 1 to 6 of 6
  1. #1
    5 Star Lounger
    Join Date
    Apr 2003
    Location
    Hampshire, United Kingdom
    Posts
    602
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Opening without running macros (Excel 2002)

    I'm writing a macro in one workbook that will extract data from a different workbook. Trouble is, this different workbook contains macros, including a Workbook_Open sub that displays a modal form on opening. As soon as the form displays, obviously all the code stops because it's waiting for a response. Is there any way for VBA to open my target workbook and disable its macros, without halting the code in the original workbook?
    Waggers
    If at first you do succeed, you've probably missed something.

  2. #2
    5 Star Lounger
    Join Date
    Apr 2003
    Location
    Hampshire, United Kingdom
    Posts
    602
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening without running macros (Excel 2002)

    Sorry to appear stupid, but no I hadn't. It works a treat - thanks v.much
    Waggers
    If at first you do succeed, you've probably missed something.

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Opening without running macros (Excel 2002)

    You are welcome, and You did NOT appear stupid.

    I did not think of this immediately, I originally looked in the OPEN method to try to find a parameter to disable them and found none.

    Steve

  4. #4
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Opening without running macros (Excel 2002)

    Have you tried disabling events before you open and then enable them afterwards:

    <pre> Application.EnableEvents = False
    Workbooks.Open "filename.xls"
    Application.EnableEvents = True
    </pre>


    Steve

  5. #5
    5 Star Lounger
    Join Date
    Apr 2003
    Location
    Hampshire, United Kingdom
    Posts
    602
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening without running macros (Excel 2002)

    Yes, I looked there too - it's the logical place for it. I suppose that's why Microsoft chose not to include it there!
    Waggers
    If at first you do succeed, you&#39;ve probably missed something.

  6. #6
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening without running macros (Excel 2002)

    Just as a general point, you don't always have to open files to extract data from them. In fact, it can improve the performance of your application significantly to extract data from a closed file. HTH
    Gre

Posting Permissions

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