avoiding VBEopen when using CreateEventProc:AGAIN

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top