ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating excel file, adding code to it from code, VBE window stays (https://www.excelbanter.com/excel-programming/435863-creating-excel-file-adding-code-code-vbe-window-stays.html)

BlueWolverine

Creating excel file, adding code to it from code, VBE window stays
 
Hello,
MS ACCESS/EXCEL 2003 on XP PRO.

I have an access database that creates/exports and excel file/application.
After the file is exported, the VBA in access adds a module and event
procedures to the excel file.

This works well so far, but while the excel application closes at the end,
the VBE (Visual Basic Editor "Code Window") window stays open. This is a
problem. Does anyone have any idea how to close the VBE window using code,
or to close out the project so the window closes, etc?

Thanks.

Below is some snippets of the code to give you an idea of some of the syntax
I'm using.
''''''''''''''''''
'Begin Code''''
''''''''''''''''''''''''''
Dim vba_editor As VBIDE.VBE
Dim vbp_access, vbp_excel As VBIDE.VBProject
Dim vbp_comp As VBIDE.VBComponent
Dim vbp_code As VBIDE.CodeModule
Dim obj_button As OLEObject
Dim lng_line As Long
Dim str_module As String

'<<<<<<<<<<<
str_wkb = str_file & str_extension
Set app_xls = Excel.Application
Set vbp_excel = app_xls.Workbooks(str_wkb).VBProject
'<<<<<<<<<<<
Set vbp_comp = vbp_excel.VBComponents.Add(vbext_ct_StdModule)
vbp_comp.Name = "C1000ToolKit"
'<<<<<<<<<<<
Set obj_button =
app_xls.Sheets("Control_Panel").OLEObjects.Add(Cla ssType:="Forms.CommandButton.1", Left:=20, Top:=int_top, Height:=20, Width:=80)
'<<<<<<<<<<<
Set vbp_code = vbp_comp.CodeModule
'<<<<<<<<<<<
With vbp_code
.InsertLines l, str_module
End With


Thanks once again.


--
BlueWolverine
MSE - Mech. Eng.
Go BLUE!


All times are GMT +1. The time now is 11:13 PM.

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