"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:
Sub A1A1()
On Error GoTo errMsg
MsgBox Application.VBE.ActiveVBProject.References.Count
errMsg:
ActiveCell = Err.Number & Err.Description
Err.Clear
End Sub
Re: "not trusted" err msg ?
See if the following link helps you:
http://support.microsoft.com/default...b;EN-US;282033
Also, there is a dedicated VBA Forum (this is a MS Excel question).
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 :)
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:
Sub A1A1()
On Error GoTo errMsg
MsgBox Application.VBE.ActiveVBProject.References.Count
errMsg:
ActiveCell = Err.Number & Err.Description
Err.Clear
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:
Sub A1A1()
On Error GoTo errMsg
MsgBox Application.VBE.ActiveVBProject.References.Count
Exit Sub
errMsg:
ActiveCell = Err.Number & Err.Description
Err.Clear
End Sub
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:
Sub PrintRef()
'PRINT TO "C:\ProjectRef.txt" PROJECT REFERENCES & DETAILS
Dim ref As Reference
Dim fn1 As Integer
On Error GoTo errMsg
fn1 = FreeFile
Open "C:\ProjectRef.txt" For Output As #fn1
Print #fn1, "Active Project References - ["; Application.VBE.ActiveVBProject.References.Count; "]"
Print #fn1, ""
For Each ref In Application.VBE.ActiveVBProject.References
With ref
Print #fn1, .Name & " " & .Major & "." & .Minor
Print #fn1, " Description: "; IIf(.IsBroken, "Broken Reference !", .Description)
Print #fn1, " Type: "; IIf(.BuiltIn, "Default - Not Removable", "Custom - Removable")
Print #fn1, " Location: "; IIf(.Type = vbext_rk_Project, "Project Module(s)", "Type Library")
Print #fn1, " Path: "; .FullPath
Print #fn1, " Class Identifier: "; IIf(.Type = vbext_rk_TypeLib, .GUID, "")
End With
Next
errMsg:
Print #fn1, ""
If Err.Number <> 0 Then
MsgBox Err.Number & " " & Err.Description
Print #fn1, " Error: " & Err.Number & " " & Err.Description
Close #fn1
Err.Clear
End If
Close #fn1
End Sub