Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Nov 2002
    Posts
    387
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro security via Automation (Excel 2000)

    Maybe this is by design but if I have an Excel template containing VBA code( macros ) and if I derived a workbook from that template from another program via automation the macros always run regardless of the Macro security setting. Surely this is not correct?

  2. #2
    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: Macro security via Automation (Excel 2000)

    I want to make sure I understand.
    Workbook A has code.
    When you open workbook A, you give permission to run the code (the macros are enabled)
    Workbook A, via code opens workbookB
    Is this your question: why do you not get any warnings on opening WorkbookB?

    You have explicitly said that workbookA's macros are fine, and so you have also implicitly told excel that any file opened by that file (workbookB) is fine, and also any file opened by WorkbookB, etc.

    Steve

  3. #3
    3 Star Lounger
    Join Date
    Nov 2002
    Posts
    387
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro security via Automation (Excel 2000)

    Let me see if I can explain this better. I have an Excel template with VBA code in it, lets call it Template A. I also have a VB 6 exe that will create an Excel Workbook from Template A using automation. Excel macro security is set to medium or high or extra high on Excel 2003. When the VB 6 app creates a workbook from template A the VBA code in the Excel template( macros ) always run and there is no prompt to enable macros.

    If using Windows explorer I double click template A and Excel Macro security is set to medium then I get prompt to enable or disable macros, if set to high or extra hing on Excel 2003 then the VBA code is never run.

    This may be by Microsoft design but it sures sounds like a security hole to me. I have a case number with Microsoft on this today.

  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: Macro security via Automation (Excel 2000)

    I pretty much stick with my same point:

    When you open TemplateA from explorer you have to explicity (or implicitly) depending on settings, allow the macros to be enabled in the workbook.

    When you run the VB6 exe you have explicitly said that the code is "ok to run" so when it creates (in code) the templateA, you have implicitly said that the code in this template is "ok to run" since it is called by a program you said was "safe". There is no need to prompt to enable macros, you have already given permission to run the macros. The code in templateA is just "an extension" of the code in the "VB6 exe".

    You don't get a "macro-warning" when you open a file via any VB code (whether thru a VB exe or thru a macro), since "by association" you have given permission already.

    Steve

Posting Permissions

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