Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm adding a whole bunch of little formatting wedges in VBA on individual
sheets as necessary. I want to call then on workbook save. This works: Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Sheet3.DoTheKludges Sheet4.DoTheKludges Sheet6.DoTheKludges Sheet9.DoTheKludges Sheet10.DoTheKludges End Sub But it's irredeemably ugly and unmaintainable and doesn't scale well as sheets get added to or subtracted from this list. So I was thinking of something along these lines: Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim objWks As Worksheet For Each objWks In Me.Worksheets On Error Resume Next objWks.DoTheKludges On Error Goto 0 Next End Sub Of course, this doesn't work since, I'm guessing, the objWks.DoTheKludges method call can't be resolved when the runtime compile occurs and that isn't trapped by the On Error. Any thoughts how to get around this? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copy Worksheet to a new Workbook creating if it doesn't exist and add more Worksheets if it does exist | Excel Programming | |||
Import a CodeModule then call its method in Workbook_Open() | Excel Programming | |||
GetObject method not work after Call Shell Method | Excel Programming | |||
How do I call a method in VB from Excel with JUST code? | Excel Programming | |||
How do I call a method in VB from Excel with JUST code? | Excel Programming |