Hi,
I am creating a spreadsheet using vbScript. The script creates a WorkBook_BeforePrint event and works fine. However, I don't want the VBA window to open when the user runs the script. Any ideas on how to suppress the VBA Window from opening?
Thanks for any help.
Tim
Tim Rutherford
I am creating a spreadsheet using vbScript. The script creates a WorkBook_BeforePrint event and works fine. However, I don't want the VBA window to open when the user runs the script. Any ideas on how to suppress the VBA Window from opening?
Code:
Const vbext_ct_StdModule = 1
Dim VBCodeMod
Dim LineNum
Dim VBComp
Dim StartLine
Set VBComp = wb.VBProject.VBComponents.Add(vbext_ct_StdModule)
'This is the print setup to be added to the Excel Workbook
With wb.VBProject.VBComponents("ThisWorkbook").CodeModule
StartLine = .CreateEventProc("BeforePrint", "Workbook") + 1
.InsertLines StartLine, _
"Dim WS As Worksheet" & Chr(13) & _
" For Each WS In Worksheets" & Chr(13) & _
" With WS.PageSetup" & Chr(13) & _
" .PrintTitleRows = ""$8:$9""" & Chr(13) & _
" .LeftHeader = Range(""B3"") & Chr(13) & Range(""B4"")" & Chr(13) &_
" .LeftFooter = ThisWorkbook.FullName" & Chr(13) & _
" .CenterFooter = ""Page &P of &N" & Chr(13) & _
" .RightFooter = ""&D" & Chr(13) & _
" .LeftMargin = Application.InchesToPoints(0.25)" & Chr(13) & _
" .RightMargin = Application.InchesToPoints(0.25)" & Chr(13) & _
" .Orientation = 2 " & Chr(13) & _
" End With" & Chr(13) & _
" Next"
End With
Tim
Tim Rutherford