A
Andyjim
Hi-
We are trying to put out a small investment system in Excel to many users.
When I run the following macro with Excel 2000 it runs fine, but when I run
it with Excel v. 2003, I get the error: Can't find project or library. I
will mark below where the error occurs. As a follow up question, will we
need to send out different macros to users depending on their version of
Excel? You guys always come through for me. Thanks in advance!
Sub PlanCa()
'Modified BevUpdate2 because it assumes
'user's filename is "UserFile.xls"
'Will also attempt to make a variable for user's file
Dim updfile As String
' Dim usrfile As String
' Dim n, p
' n = ActiveWorkbook.Name
' p = ActiveWorkbook.Path
updfile = ActiveWorkbook.Path
updfile = updfile & "\" & "devfile.xls"
' updfile = p & "\" & "devfile.xls"
' usrfile = p & "\" & n
Set usrfile = ActiveWorkbook 'HERE IS WHERE ERROR OCCURS!!!!!!!!!!
' Set updfile = updfile 'Tried to make it an object
'ERROR: REQUIRES OBJECT
'Make backup of user's file
usrfile.SaveCopyAs filename:="fxRiskMasterBackup.xls"
'Prefer "Backup" append to User's own filename,
'and save in current folder.
'Insert Filename in Filename cell
Range("Filename") = ActiveWorkbook.Name
'Copy Filename to Update file: UserFilename cell
Sheets("Lookup").Visible = True
Application.Goto Reference:="Filename"
Selection.Copy
'Workbooks.Open Filename:=updfile 'OPEN devFile
If Dir(updfile) = "" Then
MsgBox ("Devfile.xls not found. Move devfile.xls to this folder.")
Exit Sub
End If
' On Error Resume Next
' Test to see if the file is open.
If IsFileOpen(updfile) Then
' Display a message stating the file in use.
'MsgBox "File already in use!"
Else
' Display a message stating the file is not in use.
' MsgBox "File not open!"
' Open the file in Microsoft Excel.
Workbooks.Open filename:=updfile 'OPEN devFile
End If
'Workbooks.Open Filename:=updfile 'OPEN devFile
'Copy Filename to Update file: UserFilename cell
usrfile.Activate
Sheets("Lookup").Visible = True
Application.Goto Reference:="Filename"
Selection.Copy
Windows("devFile.xls").Activate
Sheets("Lookup").Visible = True
Application.Goto Reference:="userfilename"
ActiveSheet.Paste
'Copy Current Version to Update file, Old Version cell
usrfile.Activate 'WORKS!
Application.Goto Reference:="CurrentVersion"
Application.CutCopyMode = False
Selection.Copy
'Activate devFile. Can't make this happen with variable
' updfile.Activate 'ERROR: INVALID QUALIFIER
' Windows(updfile).Activate 'ERROR: SUBSCRIPT OUT OF RANGE
Windows("devFile.xls").Activate
Application.Goto Reference:="OldVersion"
ActiveSheet.Paste
'Activate Update2 macro
' Application.Run "'devFile.xls'!Update3"
' Application.Run "!Update3"
' Application.Run "'updfile'!Update3"
' Application.Run "'ActiveWorkbook'!Update2"
Application.Run "'devfile.xls'!Update2"
End Sub
We are trying to put out a small investment system in Excel to many users.
When I run the following macro with Excel 2000 it runs fine, but when I run
it with Excel v. 2003, I get the error: Can't find project or library. I
will mark below where the error occurs. As a follow up question, will we
need to send out different macros to users depending on their version of
Excel? You guys always come through for me. Thanks in advance!
Sub PlanCa()
'Modified BevUpdate2 because it assumes
'user's filename is "UserFile.xls"
'Will also attempt to make a variable for user's file
Dim updfile As String
' Dim usrfile As String
' Dim n, p
' n = ActiveWorkbook.Name
' p = ActiveWorkbook.Path
updfile = ActiveWorkbook.Path
updfile = updfile & "\" & "devfile.xls"
' updfile = p & "\" & "devfile.xls"
' usrfile = p & "\" & n
Set usrfile = ActiveWorkbook 'HERE IS WHERE ERROR OCCURS!!!!!!!!!!
' Set updfile = updfile 'Tried to make it an object
'ERROR: REQUIRES OBJECT
'Make backup of user's file
usrfile.SaveCopyAs filename:="fxRiskMasterBackup.xls"
'Prefer "Backup" append to User's own filename,
'and save in current folder.
'Insert Filename in Filename cell
Range("Filename") = ActiveWorkbook.Name
'Copy Filename to Update file: UserFilename cell
Sheets("Lookup").Visible = True
Application.Goto Reference:="Filename"
Selection.Copy
'Workbooks.Open Filename:=updfile 'OPEN devFile
If Dir(updfile) = "" Then
MsgBox ("Devfile.xls not found. Move devfile.xls to this folder.")
Exit Sub
End If
' On Error Resume Next
' Test to see if the file is open.
If IsFileOpen(updfile) Then
' Display a message stating the file in use.
'MsgBox "File already in use!"
Else
' Display a message stating the file is not in use.
' MsgBox "File not open!"
' Open the file in Microsoft Excel.
Workbooks.Open filename:=updfile 'OPEN devFile
End If
'Workbooks.Open Filename:=updfile 'OPEN devFile
'Copy Filename to Update file: UserFilename cell
usrfile.Activate
Sheets("Lookup").Visible = True
Application.Goto Reference:="Filename"
Selection.Copy
Windows("devFile.xls").Activate
Sheets("Lookup").Visible = True
Application.Goto Reference:="userfilename"
ActiveSheet.Paste
'Copy Current Version to Update file, Old Version cell
usrfile.Activate 'WORKS!
Application.Goto Reference:="CurrentVersion"
Application.CutCopyMode = False
Selection.Copy
'Activate devFile. Can't make this happen with variable
' updfile.Activate 'ERROR: INVALID QUALIFIER
' Windows(updfile).Activate 'ERROR: SUBSCRIPT OUT OF RANGE
Windows("devFile.xls").Activate
Application.Goto Reference:="OldVersion"
ActiveSheet.Paste
'Activate Update2 macro
' Application.Run "'devFile.xls'!Update3"
' Application.Run "!Update3"
' Application.Run "'updfile'!Update3"
' Application.Run "'ActiveWorkbook'!Update2"
Application.Run "'devfile.xls'!Update2"
End Sub