View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
J.W. Aldridge J.W. Aldridge is offline
external usenet poster
 
Posts: 425
Default "Run application" based on condition...

Hi.

Is there a way to add a condition before running an application?

For example, using the workbook open code below, I want to run the
application (hide_sheets) only IF applicable (only if the sheets are
hidden), otherwise bypass the command and do not give me a runtime
error.



Private Sub Workbook_Open()

Application.Run "'PCP DATA & PRODUCTION.xls'!hide_sheets"

MsgBox "Hello, welcome to PCP Data & Production" & Format(Date,
"ddd d mmm yyyy")

End Sub



///////////Actual application///////////



Sub hide_sheets()
'
' hide_sheets Macro
'

'
Sheets(Array("ROSTER", "TIMESHEET", "PRODUCTION", "INFO
SHEET")).Select
ActiveWindow.SelectedSheets.Visible = False
End Sub