View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Limey Limey is offline
external usenet poster
 
Posts: 20
Default "Run application" based on condition...

On Sep 28, 7:24 am, "J.W. Aldridge"
wrote:
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


Hi,

can't you just use an error trap?

On Error Resume Next
'statements here
on error goto 0