Results 1 to 8 of 8

Thread: Disable macro's in opening Excelsheet

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2004
    Posts
    297

    Disable macro's in opening Excelsheet

    Is there any way to open an Excelsheet in code without enabeling the macro's?
    Dim WB as WorkBook
    Set WB = Application.Workbooks.Open("filename.xls")

  2. #2
    Addicted Member
    Join Date
    Jan 2006
    Location
    Montreal, Canada
    Posts
    152

    Re: Disable macro's in opening Excelsheet

    take a look at the automationsecurity property

    should be something like
    VB Code:
    1. Application.AutomationSecurity = msoAutomationSecurityForceDisable

  3. #3
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Re: Disable macro's in opening Excelsheet

    Well you could also set the security to "very high"


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

  4. #4
    Addicted Member
    Join Date
    Jan 2006
    Location
    Montreal, Canada
    Posts
    152

    Re: Disable macro's in opening Excelsheet

    True, but if he does that, I think he won't be able to run the macro that opens his new workbook...

  5. #5
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Re: Disable macro's in opening Excelsheet

    That is the problem indeed.


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2004
    Posts
    297

    Re: Disable macro's in opening Excelsheet

    msoAutomationSecurityForceDisable is a 2003 thing
    And I ain't got 2003.

    By the way, I don't need the macro's in the sheet.
    The problem is, if I open the sheet witch contains macro's, the macro from which I open the sheet stops immediately after opening the sheet.
    Got it?

  7. #7
    Addicted Member
    Join Date
    Jan 2006
    Location
    Montreal, Canada
    Posts
    152

    Re: Disable macro's in opening Excelsheet

    Quote Originally Posted by HWijngaarD
    By the way, I don't need the macro's in the sheet.
    If you don't need the macro at all, why don't you just delete it.
    And if you need it for further uses, place them in a module.

    I don't think you can disable macro for only one sheet, you disbale it for the whole workbook. So this is why you got this problem:
    Quote Originally Posted by HWijngaarD
    The problem is, if I open the sheet witch contains macro's, the macro from which I open the sheet stops immediately after opening the sheet.

  8. #8
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Disable macro's in opening Excelsheet

    IF all of these are Event Macro, like Worksheet_Change(ByVal Target As Range), etc.

    The you can disable them by calling "Application.EnableEvents = False"

    Make sure you turn events back on when your done.
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

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