Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default "Run application" based on condition...

Thanx...

Wasnt aware of that but I'll try installing that (although I am not
too familiar with that command - will play around with it until I get
it).




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default "Run application" based on condition...


Ok... Been lookin everywhere for something to help me understand how
to work this code... Not sure. If someone can help me figure out where
to insert this and make it functional, I promise I will figure it out
from there.


On Error Resume Next
'statements here
on error goto 0


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



Thanx

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default "Run application" based on condition...

Private Sub Workbook_Open()
On Error Resume Next
Application.Run "'PCP DATA & PRODUCTION.xls'!hide_sheets"
On Error goto 0
MsgBox "Hello, welcome to PCP Data & Production" & Format(Date,
"ddd d mmm yyyy")
End Sub

--
Regards,
Tom Ogilvy


"J.W. Aldridge" wrote:


Ok... Been lookin everywhere for something to help me understand how
to work this code... Not sure. If someone can help me figure out where
to insert this and make it functional, I promise I will figure it out
from there.


On Error Resume Next
'statements here
on error goto 0


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



Thanx




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default "Run application" based on condition...

On Sep 28, 8:23 am, "J.W. Aldridge"
wrote:
Ok... Been lookin everywhere for something to help me understand how
to work this code... Not sure. If someone can help me figure out where
to insert this and make it functional, I promise I will figure it out
from there.

On Error Resume Next
'statements here
on error goto 0

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

Thanx


Hi mate,

sorry early in the morning, I should have been clearer.

Private Sub Workbook_Open()

on Error Goto skipit

Application.Run "'PCP DATA & PRODUCTION.xls'!hide_sheets"
MsgBox "Hello, welcome to PCP Data & Production" & Format(Date,
"ddd d mmm yyyy")

skipit:
End Sub

Note the On Error line with a GoTo, and then the Skipit: at the
bottom. Basically if an error is thrown, the lext line to be activated
is skipit:

Goto's aren't something you should use a lot, but I don't know there
is a choice here.

Cheers

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Lower case "a" in "application" Otto Moehrbach Excel Programming 5 August 22nd 07 01:48 AM
Macro to concatenate into "B1" B2 thru B"x" based on new data in "Col A" Dennis Excel Discussion (Misc queries) 0 July 17th 06 02:38 PM
Sending macro based e-mail with built-in "Heading" and "Text" Prabha Excel Programming 3 January 17th 05 02:11 PM
Excel VBA - go to worksheet "name" based on a cell reference ="Name" james007 Excel Programming 2 July 8th 04 11:04 PM


All times are GMT +1. The time now is 08:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"