ThisWorkbook.VBProject.References

  • Thread starter bluegrassstateworker
  • Start date
B

bluegrassstateworker

Hello all,
I have a spreadsheet that I wish to ensure that users have the TRUST
ACCESS TO VISUAL BASIC PROJECT checked. I am running a CALL
CHECKTRUST statement from the workbook_open statement. I have
computers running OfficeXP and Office2003.

When I run the code to test whether the option is checked on a machine
with Office 03 my Ref object returns a value. On a machine with
OfficeXP the Ref object returns "Nothing" even though the TRUST option
is checked. The call to AddReference in the code below removes
missing links and adds libraries based on GUIDS. Any thoughts about
making Checktrust to work on the OfficeXP machines appreaciated.
Thanks in Advance!

Sub Checktrust()
Dim Ref As Object
On Error Resume Next
Set Ref = ThisWorkbook.VBProject.References("Excel")
If Ref Is Nothing Then
MsgBox "Your Excel settings will need to be updated to run
this version of the eForm. " & vbNewLine & _
"1. From the menu, select TOOLS | MACRO | Security " &
vbNewLine & _
"2. Then go to the Trusted Sources tab, " & vbNewLine & _
"3. Check the box { TRUST ACCESS TO VISUAL BASIC PROJECT }
setting" & vbNewLine & _
"4. Exit Excel then open this file again. This is needed only
once", vbOKOnly
Else
Call AddReference
End If
endsub
 
J

Jim Rech

This is how I determine if VB access is trusted:

Sub TestVBE_Trusted()
If VBE_Trusted Then
MsgBox "VBE Trusted"
Else
MsgBox "VBE NOT Trusted"
End If
End Sub

Function VBE_Trusted() As Boolean
Dim X As Variant
On Error Resume Next
Err.Clear
X = Application.VBE.Version
VBE_Trusted = (Err.Number = 0)
End Function

--
Jim
| Hello all,
| I have a spreadsheet that I wish to ensure that users have the TRUST
| ACCESS TO VISUAL BASIC PROJECT checked. I am running a CALL
| CHECKTRUST statement from the workbook_open statement. I have
| computers running OfficeXP and Office2003.
|
| When I run the code to test whether the option is checked on a machine
| with Office 03 my Ref object returns a value. On a machine with
| OfficeXP the Ref object returns "Nothing" even though the TRUST option
| is checked. The call to AddReference in the code below removes
| missing links and adds libraries based on GUIDS. Any thoughts about
| making Checktrust to work on the OfficeXP machines appreaciated.
| Thanks in Advance!
|
| Sub Checktrust()
| Dim Ref As Object
| On Error Resume Next
| Set Ref = ThisWorkbook.VBProject.References("Excel")
| If Ref Is Nothing Then
| MsgBox "Your Excel settings will need to be updated to run
| this version of the eForm. " & vbNewLine & _
| "1. From the menu, select TOOLS | MACRO | Security " &
| vbNewLine & _
| "2. Then go to the Trusted Sources tab, " & vbNewLine & _
| "3. Check the box { TRUST ACCESS TO VISUAL BASIC PROJECT }
| setting" & vbNewLine & _
| "4. Exit Excel then open this file again. This is needed only
| once", vbOKOnly
| Else
| Call AddReference
| End If
| endsub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top