forcing specific sheet opening upon launch of .xlsx file
Hi Art,
The following macros should work. Basically, it will take the target workbook file path and name and check to see if it is open. If not, it will open the workbook. Next, it will look for a sheet called "Disclaimer" and move it to the front of the workbook. You can adjust this macro to fit your needs. For example, you could link the file path and/or workbook name to cells in your macro workbook.
Hope this helps,
Ben
Sub MoveSheet()
Dim sWB As String 'Workbook Name with extension
Dim sFP As String 'Filepath
Dim WB As Workbook 'Workbook
sWB = "MyWorkbook.xlsx" 'Range("A1")
sFP = "C:\Desktop\" 'Range("A2")
If BookOpen(sWB) = False Then _
Workbooks.Open sFP & sWB, False, False
Set WB = Workbooks(sWB)
WB.Sheets("Disclaimer").Move Befo=WB.Sheets(1)
End Sub
Function BookOpen(WBk As String) As Boolean
'Checks whether a workbook is open
BookOpen = False
On Error GoTo NotOpen
Application.DisplayAlerts = False
Workbooks(WBk).Activate
BookOpen = True
NotOpen:
Err.Clear
End Function
|