lpking2005
Board Regular
- Joined
- Mar 21, 2011
- Messages
- 140
hi, im in need of some help...
I currently have the below code, which opens a workbook.
What i need to do is adjust this code so that when the timesheet workbook opens, it then runs a macro which is contained within that workbook called "GotoBOS2" and if the timesheet is already open, switch to that workbook and activate the same macro.
Any help would be greatly appreciated!
I currently have the below code, which opens a workbook.
Code:
Sub Open_BOS()
' OPEN TIMESHEET
Line = Right(Sheets("HOME PAGE").Range("A1").Value, 3)
monthCode = Sheets("HOME PAGE").Range("B14").Value
If Len(Month(monthCode)) = 1 Then
monthCode = Year(monthCode) & "0" & Month(monthCode)
Else
monthCode = Year(monthCode) & Month(monthCode)
End If
tspath = "T:\Production\PROD MOULDING\" & Line & " Time Sheets\" & Line & " Time Sheet " & monthCode
timesheet = Line & " Time Sheet " & monthCode
On Error GoTo errorhandler
errcode = 1
Windows(timesheet).Activate
'''' Application.Run "'" & timesheet & "'" & "!GoToBOS2"
If errcode = 2 Then
Workbooks.Open fileName:=tspath, UpdateLinks:=0, ReadOnly:=0
End If
Exit Sub
errorhandler:
If errcode = 2 Then
errcode = 0
Else
errcode = 2
End If
Resume Next
End Sub
What i need to do is adjust this code so that when the timesheet workbook opens, it then runs a macro which is contained within that workbook called "GotoBOS2" and if the timesheet is already open, switch to that workbook and activate the same macro.
Any help would be greatly appreciated!