Results 1 to 5 of 5

Thread: "not trusted" err msg ? [RESOLVED] added code..

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    TZI Transition Date
    Posts
    272

    Resolved "not trusted" err msg ? [RESOLVED] added code..

    anyone know why i get this error ?
    1004Programmatic access to Visual Basic Project is not trusted

    also if i just run [MsgBox Application.VBE.ActiveVBProject.References.Count] without error handling i get:
    1004Method 'VBE' of object '_Application' failed
    - BUT, only on the second and subsequent attempts...

    from excel run:
    VB Code:
    1. Sub A1A1()
    2.     On Error GoTo errMsg
    3.     MsgBox Application.VBE.ActiveVBProject.References.Count
    4. errMsg:
    5.     ActiveCell = Err.Number & Err.Description
    6.     Err.Clear
    7. End Sub
    Last edited by MJBNET; Mar 26th, 2005 at 05:43 PM. Reason: added results

  2. #2

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    TZI Transition Date
    Posts
    272

    Re: "not trusted" err msg ?

    tkx RhinoBull..! exactly right...

    yeah, i sometimes wonder what forum to post in because i see api and vba posts here all the time. strictly speaking i should prolly post everything in the vba forum since i only work in excel and don't even have vb, but i use it and api all the time... anyway i'll try to be more specific on the postings tkx

  4. #4
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808

    Re: "not trusted" err msg ? [RESOLVED]

    Quote Originally Posted by MJBNET
    anyone know why i get this error ?
    1004Programmatic access to Visual Basic Project is not trusted

    also if i just run [MsgBox Application.VBE.ActiveVBProject.References.Count] without error handling i get:
    1004Method 'VBE' of object '_Application' failed
    - BUT, only on the second and subsequent attempts...

    from excel run:
    VB Code:
    1. Sub A1A1()
    2.     On Error GoTo errMsg
    3.     MsgBox Application.VBE.ActiveVBProject.References.Count
    4. errMsg:
    5.     ActiveCell = Err.Number & Err.Description
    6.     Err.Clear
    7. End Sub
    Also, I think you need an Exit Sub to avoid the ActiveCell being written with "0" if no error has raised.

    VB Code:
    1. Sub A1A1()
    2.     On Error GoTo errMsg
    3.     MsgBox Application.VBE.ActiveVBProject.References.Count
    4.     Exit Sub
    5.  
    6. errMsg:
    7.     ActiveCell = Err.Number & Err.Description
    8.     Err.Clear
    9. End Sub
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    TZI Transition Date
    Posts
    272

    Re: "not trusted" err msg ? [RESOLVED] added code..

    just thought i'd post where i went with this...it returns the details about each reference like:
    '----------------------
    VBA 4.0
    Description: Visual Basic For Applications
    Type: Default - Not Removable
    Location: Type Library
    Path: C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6.DLL
    Class Identifier: {000204EF-0000-0000-C000-000000000046}
    '----------------------
    VB Code:
    1. Sub PrintRef()
    2. 'PRINT TO "C:\ProjectRef.txt" PROJECT REFERENCES & DETAILS
    3.     Dim ref As Reference
    4.     Dim fn1 As Integer
    5.    
    6.     On Error GoTo errMsg
    7.     fn1 = FreeFile
    8.     Open "C:\ProjectRef.txt" For Output As #fn1
    9.     Print #fn1, "Active Project References - ["; Application.VBE.ActiveVBProject.References.Count; "]"
    10.     Print #fn1, ""
    11.     For Each ref In Application.VBE.ActiveVBProject.References
    12.         With ref
    13.             Print #fn1, .Name & " " & .Major & "." & .Minor
    14.             Print #fn1, "     Description: "; IIf(.IsBroken, "Broken Reference !", .Description)
    15.             Print #fn1, "     Type: "; IIf(.BuiltIn, "Default - Not Removable", "Custom - Removable")
    16.             Print #fn1, "     Location: "; IIf(.Type = vbext_rk_Project, "Project Module(s)", "Type Library")
    17.             Print #fn1, "     Path: "; .FullPath
    18.             Print #fn1, "     Class Identifier: "; IIf(.Type = vbext_rk_TypeLib, .GUID, "")
    19.         End With
    20.     Next
    21. errMsg:
    22.     Print #fn1, ""
    23.     If Err.Number <> 0 Then
    24.         MsgBox Err.Number & " " & Err.Description
    25.         Print #fn1, "     Error: " & Err.Number & " " & Err.Description
    26.         Close #fn1
    27.         Err.Clear
    28.     End If
    29.     Close #fn1
    30. End Sub

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