ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ThisWorkbook.VBProject.References (https://www.excelbanter.com/excel-programming/403580-thisworkbook-vbproject-references.html)

bluegrassstateworker

ThisWorkbook.VBProject.References
 
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

Jim Rech[_2_]

ThisWorkbook.VBProject.References
 
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
"bluegrassstateworker" wrote in message
...
| 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




All times are GMT +1. The time now is 04:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com