View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
John Bundy John Bundy is offline
external usenet poster
 
Posts: 772
Default workbookbeforesave

That one took me a minute, first i don't see where you are setting wb = to
the workbook, but more likely the problem is that arrays are option base 0,
so putting a 4 will cause a subscript error and the others won't match.
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


" wrote:

Hi,

I writing a workbookbeforesave event but can't get my
PageSetup.LeftFooter to work. The event is executed it is just the
Pagesetup that doesn't work. Is there any known problem with this? I
running excel 2003 sp2.

ws.PageSetup.CenterHeader = "test" '''doesn't work
ws.Range("A4") = "test" ''' works

Code in a Class Module:

Public WithEvents App As Application
Private Sub App_WorkbookBeforeSave(ByVal Wb As Workbook, ByVal
SaveAsUI As Boolean, Cancel As Boolean)

Dim SecurityLevel()

SecurityLevel = Array("Secret", "Confidential", "Proprietary",
"Public")

On Error Resume Next
Do Until Level = 1 Or Level = 2 Or Level = 3 Or Level = 4
Level = InputBox("To AFR secure this document type in security
level, otherwise cancel.1 = Secret, 2 = Confidential, 3 = Proprietary
and 4 = Public.", "Update the date")
If Level = 0 Then
Exit Sub ''' Cancel pressed
End If
Loop

Wb.Worksheets("Sheet1").PageSetup.LeftFooter =
Application.UserName & ", " & "&D" & Chr(10) & "Security Class <" &
SecurityLevel(Level) & ""

However this works

ws.Worksheets("Sheet1").Range("A2") = "test"

End Sub

Regards

JS