Results 1 to 2 of 2
  1. #1
    Star Lounger
    Join Date
    Oct 2002
    Location
    Blue Mountains, New South Wales, Australia
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Open file disable macros (Excel 97/vba)

    I have a macro in an excel workbook which opens another excel workbook. I wish to DISABLE MACROS in the second workbook, read from it, then close without saving changes.
    Workbooks.Open sFile 'sFile is variable with path+name of second workbook
    sFormName = ActiveWorkbook.Name
    ....
    Workbooks(sFormName).Close SaveChanges:=False, routeworkbook:=False

    Can anyone help me disable all macros within sFile when it opens.

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open file disable macros (Excel 97/vba)

    You cannot disable macros for workbooks opened using VBA, but you CAN prevent their Workbook_Open macro from running:

    Application.EnableEvents=False
    Workbooks.Open sFile
    Application.EnableEvents=True
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

Posting Permissions

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