+ Reply to Thread
Results 1 to 3 of 3

Programmatically finding out if Excel macros are enabled.

Hybrid View

  1. #1
    Zhwgnon Flrq
    Guest

    Programmatically finding out if Excel macros are enabled.

    How can I find out through VB 6.0 whether macros are enable in an Excel 2003
    application?

    I tried the following but it does not work:

    Set ea = CreateObject ("Excel.Application")

    ' test.xls has macros
    Set wb = ea.Workbooks.Open ("e:\test.xls")

    ' This line bombs out
    MsgBox (ea.VBE.VBProjects.Count)

    Any help will be appreciated. Thanks.

  2. #2
    Tim Williams
    Guest

    Re: Programmatically finding out if Excel macros are enabled.

    Have you added a reference to the VBE library?
    What is the text of the error you get?

    Tim

    --
    Tim Williams
    Palo Alto, CA


    "Zhwgnon Flrq" <Zhwgnon [email protected]> wrote in message
    news:[email protected]...
    > How can I find out through VB 6.0 whether macros are enable in an Excel

    2003
    > application?
    >
    > I tried the following but it does not work:
    >
    > Set ea = CreateObject ("Excel.Application")
    >
    > ' test.xls has macros
    > Set wb = ea.Workbooks.Open ("e:\test.xls")
    >
    > ' This line bombs out
    > MsgBox (ea.VBE.VBProjects.Count)
    >
    > Any help will be appreciated. Thanks.




  3. #3
    Zhwgnon Flrq
    Guest

    Re: Programmatically finding out if Excel macros are enabled.

    I got the solution.

    The text of the error message was: Programmatic Access to Visual Basic
    Project is unsafe.

    The code was written against Excel 2000, but in XP and 2003, security has
    been enhanced. The solution is documented here:
    http://support.microsoft.com/kb/q282830/

    "Tim Williams" wrote:

    > Have you added a reference to the VBE library?
    > What is the text of the error you get?
    >
    > Tim
    >
    > --
    > Tim Williams
    > Palo Alto, CA
    >
    >
    > "Zhwgnon Flrq" <Zhwgnon [email protected]> wrote in message
    > news:[email protected]...
    > > How can I find out through VB 6.0 whether macros are enable in an Excel

    > 2003
    > > application?
    > >
    > > I tried the following but it does not work:
    > >
    > > Set ea = CreateObject ("Excel.Application")
    > >
    > > ' test.xls has macros
    > > Set wb = ea.Workbooks.Open ("e:\test.xls")
    > >
    > > ' This line bombs out
    > > MsgBox (ea.VBE.VBProjects.Count)
    > >
    > > Any help will be appreciated. Thanks.

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1