+ Reply to Thread
Results 1 to 3 of 3

Visual Basic References

  1. #1
    Jason Zischke
    Guest

    Visual Basic References

    Hi all,

    I want my program to automatically install all the applicable references and
    I found a bit of code that looked like it would work however it didn't it
    came up with 'error 1004 Programmatic access to Visual Basic Project is not
    trusted'.How can I get arround this, below is my code.

    Private Sub Workbook_Open()
    'Visual Basic for Applications
    ThisWorkbook.VBProject.References.AddFromFile ("C:\Program Files\Common
    Files\Microsoft Shared\VBA\VBA6\VBE6.DLL")
    'Microsoft Excel 11 Object Library
    ThisWorkbook.VBProject.References.AddFromFile ("C:\Program Files\Microsoft
    Office\OFFICE11\EXCEL.EXE")
    'OLE Automation
    ThisWorkbook.VBProject.References.AddFromFile
    ("C:\WINDOWS\system32\STDOLE2.TLB")
    'Microsoft Office 11 Object Library
    ThisWorkbook.VBProject.References.AddFromFile ("C:\Program Files\Common
    Files\Microsoft Shared\OFFICE11\MSO.DLL")
    'Microsoft Forms 2.0 Object Library
    ThisWorkbook.VBProject.References.AddFromFile ("C:\WINDOWS\system32\FM20.DLL")
    'Microsoft Office Web Components 11.0
    ThisWorkbook.VBProject.References.AddFromFile ("C:\Program Files\Common
    Files\Microsoft Shared\Web Components\11\OWC11.DLL")
    'Microsoft Office Web Components 9.0
    ThisWorkbook.VBProject.References.AddFromFile ("C:\Program Files\Microsoft
    Office\Office\MSOWC.DLL")
    End Sub

    Thanks in adavnce

    Jason



  2. #2
    Jim Thomlinson
    Guest

    RE: Visual Basic References

    Here is an excerpt from Chip Pearson's web site...

    NOTE: In all versions of Excel, the VBProject must not be protected. If it
    is, these procedures will fail. There is no programmatic way to unlock a
    locked project. In Excel 2002, you must have "Trust Access To Visual Basic
    Project" enabled. To enable this setting, go to the Tools menu in Excel,
    choose Macros, Security, then the "Trusted Sources" tab, and put a check next
    to "Trust Access To Visual Basic Project". Otherwise, you will get errors.

    Here is the link...
    http://www.cpearson.com/excel/vbe.htm


    --
    HTH...

    Jim Thomlinson


    "Jason Zischke" wrote:

    > Hi all,
    >
    > I want my program to automatically install all the applicable references and
    > I found a bit of code that looked like it would work however it didn't it
    > came up with 'error 1004 Programmatic access to Visual Basic Project is not
    > trusted'.How can I get arround this, below is my code.
    >
    > Private Sub Workbook_Open()
    > 'Visual Basic for Applications
    > ThisWorkbook.VBProject.References.AddFromFile ("C:\Program Files\Common
    > Files\Microsoft Shared\VBA\VBA6\VBE6.DLL")
    > 'Microsoft Excel 11 Object Library
    > ThisWorkbook.VBProject.References.AddFromFile ("C:\Program Files\Microsoft
    > Office\OFFICE11\EXCEL.EXE")
    > 'OLE Automation
    > ThisWorkbook.VBProject.References.AddFromFile
    > ("C:\WINDOWS\system32\STDOLE2.TLB")
    > 'Microsoft Office 11 Object Library
    > ThisWorkbook.VBProject.References.AddFromFile ("C:\Program Files\Common
    > Files\Microsoft Shared\OFFICE11\MSO.DLL")
    > 'Microsoft Forms 2.0 Object Library
    > ThisWorkbook.VBProject.References.AddFromFile ("C:\WINDOWS\system32\FM20.DLL")
    > 'Microsoft Office Web Components 11.0
    > ThisWorkbook.VBProject.References.AddFromFile ("C:\Program Files\Common
    > Files\Microsoft Shared\Web Components\11\OWC11.DLL")
    > 'Microsoft Office Web Components 9.0
    > ThisWorkbook.VBProject.References.AddFromFile ("C:\Program Files\Microsoft
    > Office\Office\MSOWC.DLL")
    > End Sub
    >
    > Thanks in adavnce
    >
    > Jason
    >
    >


  3. #3
    Bob Phillips
    Guest

    Re: Visual Basic References

    Hi Jason,

    Excel 2002 added a new security setting was added whereby you must grant
    access in order to manipulate objects that are part of the VBProject with
    VBA.

    From the menu Tools/Macro/Security, select the Trusted Sources tab and check
    "Trust Access to Visual Basic Project".

    --

    HTH

    Bob Phillips

    (remove nothere from the email address if mailing direct)

    "Jason Zischke" <[email protected]> wrote in message
    news:[email protected]...
    > Hi all,
    >
    > I want my program to automatically install all the applicable references

    and
    > I found a bit of code that looked like it would work however it didn't it
    > came up with 'error 1004 Programmatic access to Visual Basic Project is

    not
    > trusted'.How can I get arround this, below is my code.
    >
    > Private Sub Workbook_Open()
    > 'Visual Basic for Applications
    > ThisWorkbook.VBProject.References.AddFromFile ("C:\Program Files\Common
    > Files\Microsoft Shared\VBA\VBA6\VBE6.DLL")
    > 'Microsoft Excel 11 Object Library
    > ThisWorkbook.VBProject.References.AddFromFile ("C:\Program Files\Microsoft
    > Office\OFFICE11\EXCEL.EXE")
    > 'OLE Automation
    > ThisWorkbook.VBProject.References.AddFromFile
    > ("C:\WINDOWS\system32\STDOLE2.TLB")
    > 'Microsoft Office 11 Object Library
    > ThisWorkbook.VBProject.References.AddFromFile ("C:\Program Files\Common
    > Files\Microsoft Shared\OFFICE11\MSO.DLL")
    > 'Microsoft Forms 2.0 Object Library
    > ThisWorkbook.VBProject.References.AddFromFile

    ("C:\WINDOWS\system32\FM20.DLL")
    > 'Microsoft Office Web Components 11.0
    > ThisWorkbook.VBProject.References.AddFromFile ("C:\Program Files\Common
    > Files\Microsoft Shared\Web Components\11\OWC11.DLL")
    > 'Microsoft Office Web Components 9.0
    > ThisWorkbook.VBProject.References.AddFromFile ("C:\Program Files\Microsoft
    > Office\Office\MSOWC.DLL")
    > End Sub
    >
    > Thanks in adavnce
    >
    > Jason
    >
    >




+ 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