ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   avoiding VBEopen when using CreateEventProc:AGAIN (https://www.excelbanter.com/excel-programming/319208-avoiding-vbeopen-when-using-createeventproc-again.html)

[email protected][_2_]

avoiding VBEopen when using CreateEventProc:AGAIN
 
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



All times are GMT +1. The time now is 05:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com