SherryO
12-19-2006, 09:13 AM
Hi,
I'm using the following code to modify personal.xls on open from another file to install a toolbar and menu items. When I run it on other's machines, I get an error that the source is not trusted. Can anyone help me get beyond this message?
Thank you so much.
Sub ModToPersonal()
Application.ScreenUpdating = False
Dim Filt As String, Title As String, FilterIndex As Integer, i As Integer, FileName
Dim blnPersonal As Boolean
Dim FSO As Object, Folder As Object, File As Object
Dim PersonalXLS As Workbook
'****Create an instance of the FileSystemObject and obtain the excel startup folder
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Folder = FSO.GetFolder(Application.StartupPath)
'****See if Personal.xls already exists
For Each File In Folder.Files
If UCase(File.Name) = "PERSONAL.XLS" Then
If WorkbookIsOpen(File.Name) Then
Set PersonalXLS = Application.Workbooks(File.Name)
Else
Set PersonalXLS = Application.Workbooks.Open(File.Path)
End If
blnPersonal = True
Exit For
End If
Next
'****If Personal.xls was not found, create Personal.xls workbook and hide it
If blnPersonal = False Then
Set PersonalXLS = Application.Workbooks.Add
PersonalXLS.SaveAs (Application.StartupPath & "\PERSONAL.xls")
Windows("PERSONAL.xls").Visible = False
End If
PersonalXLS.VBProject.VBComponents.Import ("c:\Project Management\Admin\Code\SensisPM.bas")
ExitHere:
'****Clean up
PersonalXLS.Save
Set PersonalXLS = Nothing
Set FSO = Nothing
Set Folder = Nothing
Set File = Nothing
Application.ScreenUpdating = True
End Sub
'Function thanks to John Walkenbach
Private Function WorkbookIsOpen(wbName) As Boolean
'Returns TRUE if the workbook is open
Dim wb As Workbook
On Error Resume Next
Set wb = Application.Workbooks(wbName)
If Err = 0 Then WorkbookIsOpen = True Else WorkbookIsOpen = False
End Function
I'm using the following code to modify personal.xls on open from another file to install a toolbar and menu items. When I run it on other's machines, I get an error that the source is not trusted. Can anyone help me get beyond this message?
Thank you so much.
Sub ModToPersonal()
Application.ScreenUpdating = False
Dim Filt As String, Title As String, FilterIndex As Integer, i As Integer, FileName
Dim blnPersonal As Boolean
Dim FSO As Object, Folder As Object, File As Object
Dim PersonalXLS As Workbook
'****Create an instance of the FileSystemObject and obtain the excel startup folder
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Folder = FSO.GetFolder(Application.StartupPath)
'****See if Personal.xls already exists
For Each File In Folder.Files
If UCase(File.Name) = "PERSONAL.XLS" Then
If WorkbookIsOpen(File.Name) Then
Set PersonalXLS = Application.Workbooks(File.Name)
Else
Set PersonalXLS = Application.Workbooks.Open(File.Path)
End If
blnPersonal = True
Exit For
End If
Next
'****If Personal.xls was not found, create Personal.xls workbook and hide it
If blnPersonal = False Then
Set PersonalXLS = Application.Workbooks.Add
PersonalXLS.SaveAs (Application.StartupPath & "\PERSONAL.xls")
Windows("PERSONAL.xls").Visible = False
End If
PersonalXLS.VBProject.VBComponents.Import ("c:\Project Management\Admin\Code\SensisPM.bas")
ExitHere:
'****Clean up
PersonalXLS.Save
Set PersonalXLS = Nothing
Set FSO = Nothing
Set Folder = Nothing
Set File = Nothing
Application.ScreenUpdating = True
End Sub
'Function thanks to John Walkenbach
Private Function WorkbookIsOpen(wbName) As Boolean
'Returns TRUE if the workbook is open
Dim wb As Workbook
On Error Resume Next
Set wb = Application.Workbooks(wbName)
If Err = 0 Then WorkbookIsOpen = True Else WorkbookIsOpen = False
End Function