M
matthewgdodds
Sorry folks, need to come back to the experts again on this.
The suggestion received was that using
Application.VBE.MainWindow.visible = False would prevent the VBE from
becoming visible when writing an event into a Sheet Module using
CreateEventProc.
The immediate window certainly shows this turns visibility off, but
calling my method with the CreateEventProc code apparently turns
visibility back ON! (see below)
code snippet is
Application.VBE.MainWindow.visible = False
Debug.Print "Application.VBE.MainWindow.visible(1)?: " &
Application.VBE.MainWindow.visible
Call commonFunctions.insertSelectionChange(wkbNew)
Debug.Print "Application.VBE.MainWindow.visible(2)?: " &
Application.VBE.MainWindow.visible
resulting immediate window is
Application.VBE.MainWindow.visible(1): False
Application.VBE.MainWindow.visible(2): True
The insertSelectionChange function is
Function insertSelectionChange(wkbNew As Workbook)
Dim startPoint As Long
With wkbNew.VBProject.VBComponents("sheet2").CodeModule
startPoint = .CreateEventProc("selectionChange", "worksheet") + 1
..InsertLines startPoint, "'Application.ScreenUpdating = true" &
Chr(13) & _
-- BULK CODE CUT HERE --
" If selection.Row = 1 Or _" & Chr(13) & _
" End If"
End With
End Function
Suggestions gratefully received
Matthew
The suggestion received was that using
Application.VBE.MainWindow.visible = False would prevent the VBE from
becoming visible when writing an event into a Sheet Module using
CreateEventProc.
The immediate window certainly shows this turns visibility off, but
calling my method with the CreateEventProc code apparently turns
visibility back ON! (see below)
code snippet is
Application.VBE.MainWindow.visible = False
Debug.Print "Application.VBE.MainWindow.visible(1)?: " &
Application.VBE.MainWindow.visible
Call commonFunctions.insertSelectionChange(wkbNew)
Debug.Print "Application.VBE.MainWindow.visible(2)?: " &
Application.VBE.MainWindow.visible
resulting immediate window is
Application.VBE.MainWindow.visible(1): False
Application.VBE.MainWindow.visible(2): True
The insertSelectionChange function is
Function insertSelectionChange(wkbNew As Workbook)
Dim startPoint As Long
With wkbNew.VBProject.VBComponents("sheet2").CodeModule
startPoint = .CreateEventProc("selectionChange", "worksheet") + 1
..InsertLines startPoint, "'Application.ScreenUpdating = true" &
Chr(13) & _
-- BULK CODE CUT HERE --
" If selection.Row = 1 Or _" & Chr(13) & _
" End If"
End With
End Function
Suggestions gratefully received
Matthew