Hi, Erikje,
thereīs no need to use a modal-wide variable to pass the the string, it could be done by passing the string as a parameter (this would avoid anybody starting the procedure on itīs own when no value has been assigned to the variable which would result in a run-time error.
Dim ScorecardFile As String
Sub StartOpen()
ScorecardFile = "C:\Scorecard\TestingNew\PopPVs.xlsx"
Application.Run "SoftcodeFileOpen"
End Sub
Sub SoftcodeFileOpen()
Dim wb As Workbook
Set wb = Workbooks.Open(Filename:=ScorecardFile)
Windows("PopRatings.xlsx").Activate
wb.Activate '************This line causes the error below
'...
Set wb = Nothing
End Sub
Thereīs also no need to jump between workbooks (btw: the window will only display the name of the workbook, not the full path and name, so only the last part of the string should be used using InStrRev to find the last \).
Please add Code-Tags to your code for better readability.
Ciao,
Holger
Bookmarks