Consulting

Page 2 of 2 FirstFirst 1 2
Results 21 to 29 of 29

Thread: Opened Workbooks are still opened after executing Macro (Workbook.Close doesn't work)

  1. #21
    Workbooks.Open doesn't cause the Enable macro's pop-up. At least, it hasn't done that for over two decades.
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  2. #22
    Quote Originally Posted by Jan Karel Pieterse View Post
    Workbooks.Open doesn't cause the Enable macro's pop-up. At least, it hasn't done that for over two decades.
    ok, i thought you mean that with this comment you made:
    So, something causes a workbook with macro's to be opened in Excel.
    Do you have an idea how to do a workaround to this problem?

  3. #23
    No, I think I would need your full Excel project (and accompanying files) to troubleshoot this, not just some VBA code.
    You need to find out what exactly causes the file to open and trigger the macro warning dialog. Anything goes for that matter, Autohotkey?
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  4. #24
    Quote Originally Posted by Jan Karel Pieterse View Post
    No, I think I would need your full Excel project (and accompanying files) to troubleshoot this, not just some VBA code.
    You need to find out what exactly causes the file to open and trigger the macro warning dialog. Anything goes for that matter, Autohotkey?
    I replicated my files and attached them! But with this file, the problem does not appear!!! The only differences between those files are the complexity. The original Excel file i sadly cannot share has 30 worksheets and 5MB (like the PPT). Everythink else it the same. I dont use autohotkey.

    I filmed it so you see where the security window appears. Here is the video (too big to attach it): https://drive.google.com/file/d/1HGV...ew?usp=sharing
    Attached Files Attached Files
    Last edited by o0omax; 08-16-2022 at 01:45 PM.

  5. #25
    What happens if you change the .Open line to this:
            Dim autom As Long
            autom = Application.AutomationSecurity
            Application.AutomationSecurity = msoAutomationSecurityForceDisable
            Set wb = Workbooks.Open(folderName & "\" & DateiName & ".xlsm")
            Application.AutomationSecurity = autom
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  6. #26
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,058
    Location
    @JKP, Are all "Application.( what ever)" declared as Long's?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  7. #27
    Quote Originally Posted by Jan Karel Pieterse View Post
    What happens if you change the .Open line to this:
            Dim autom As Long
            autom = Application.AutomationSecurity
            Application.AutomationSecurity = msoAutomationSecurityForceDisable
            Set wb = Workbooks.Open(folderName & "\" & DateiName & ".xlsm")
            Application.AutomationSecurity = autom
    I tested it and one out of two files (1st one) which have been created did not close.

    Occasionaly it works and all get closed. Most of the times the macro security pops up somewhere after the .Open command (e.g. when pasting to PowerPoint).

    What i dont undetstand: Why does it work with the file i provided you but not with my original file, when the code is identical?

  8. #28
    Not by definition. But most (if not all) are simple enumerations which are fine to declare as long and I was too lazy to go and search for the name of the "group of options" belonging to that particular setting so I could declare "dim autom as msoAutomationSecurity".
    If you run ?typename(msoAutomationSecurityLow) in the immediate window it says Long.
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  9. #29
    I don't know why it doesn't work with your original. Have you tried cleaning the VBA project? http://www.appspro.com/Utilities/CodeCleaner.htm
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

Posting Permissions

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