A
Aldo
Hi guys,
This is my very first time in this discussion group.
I work on an application that should run under both Excel 11.0 and Excel 12.0
I am automating Excel with the application NOT visible, but when running the
code below, the VBA Editor flashes on-screen.
How can I suppress that "flashing"?
Thanks in advance,
Aldo.
The following block of code should create a Sub into "ThisWorkbook".
Sub Create_Workbook_BeforeCloseSub()
Dim VBProj As VBIDE.VBProject
Dim VBComp As VBIDE.VBComponent
Dim CodeMod As VBIDE.CodeModule
Dim LineNum As Long
Const DQUOTE = """" 'one " character
Set VBProj = ActiveWorkbook.VBProject
Set VBComp = VBProj.VBComponents(ActiveWorkbook.CodeName)
Set CodeMod = VBComp.CodeModule
With CodeMod
LineNum = LineNum + 1: .InsertLines LineNum, "Option Explicit"
LineNum = .CreateEventProc("BeforeClose", "Workbook")
LineNum = LineNum + 1: .InsertLines LineNum, "
ActiveWorkbook.Close(False)"
End With
'Close VBA editor
Application.VBE.MainWindow.Visible = False
End Sub
This is my very first time in this discussion group.
I work on an application that should run under both Excel 11.0 and Excel 12.0
I am automating Excel with the application NOT visible, but when running the
code below, the VBA Editor flashes on-screen.
How can I suppress that "flashing"?
Thanks in advance,
Aldo.
The following block of code should create a Sub into "ThisWorkbook".
Sub Create_Workbook_BeforeCloseSub()
Dim VBProj As VBIDE.VBProject
Dim VBComp As VBIDE.VBComponent
Dim CodeMod As VBIDE.CodeModule
Dim LineNum As Long
Const DQUOTE = """" 'one " character
Set VBProj = ActiveWorkbook.VBProject
Set VBComp = VBProj.VBComponents(ActiveWorkbook.CodeName)
Set CodeMod = VBComp.CodeModule
With CodeMod
LineNum = LineNum + 1: .InsertLines LineNum, "Option Explicit"
LineNum = .CreateEventProc("BeforeClose", "Workbook")
LineNum = LineNum + 1: .InsertLines LineNum, "
ActiveWorkbook.Close(False)"
End With
'Close VBA editor
Application.VBE.MainWindow.Visible = False
End Sub