Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How can I write a code from procedure to some Workbook's
ThisWorkbook? With procedure1 a make Workbook with a table. I need to write Auto_Close procedure to ThisWorkbook which makes some controls before I close it. Is it possible? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
http://www.cpearson.com/excel/vbe.htm
auto_close goes in a general module, not the thisworkbook module. BeforeClose is the event equivalent placed in ThisWorkbook module. -- Regards, Tom Ogilvy "JJ" wrote in message ... How can I write a code from procedure to some Workbook's ThisWorkbook? With procedure1 a make Workbook with a table. I need to write Auto_Close procedure to ThisWorkbook which makes some controls before I close it. Is it possible? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() -----Original Message----- http://www.cpearson.com/excel/vbe.htm auto_close goes in a general module, not the thisworkbook module. BeforeClose is the event equivalent placed in ThisWorkbook module. -- Regards, Tom Ogilvy "JJ" wrote in message ... How can I write a code from procedure to some Workbook's ThisWorkbook? With procedure1 a make Workbook with a table. I need to write Auto_Close procedure to ThisWorkbook which makes some controls before I close it. Is it possible? . sorry I wrote auto_close. but question is if it is possible to put code with another code to BeforeClose? thanks |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here is an example
'---------------------------------------------------------------- Sub AddWorkbookEventProc() '---------------------------------------------------------------- Dim StartLine As Long With ActiveWorkbook.VBProject.VBComponents("ThisWorkboo k").CodeModule StartLine = .CreateEventProc("BeforeClose", "Workbook") + 1 .InsertLines StartLine, _ "Dim ans" & vbCrLf & _ " ans = Msgbox( ""All OK"",vbOYesNo)" & vbCrLf & _ " If ans = vbNo Then Cancel = True" End With End Sub -- HTH RP (remove nothere from the email address if mailing direct) "JJ" wrote in message ... How can I write a code from procedure to some Workbook's ThisWorkbook? With procedure1 a make Workbook with a table. I need to write Auto_Close procedure to ThisWorkbook which makes some controls before I close it. Is it possible? |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
try something like this:
=== EXAMPLE ============== Dim lLine, xCodeModule, VBE Set VBE = ThisWorkbook.VBProject Set xCodeModule = VBE.VBComponents("ThisWorkbook").CodeModule lLine = xCodeModule.CreateEventProc("BeforeClose", "Workbook") xCodeModule.InsertLines lLine + 1, "Msgbox ""before Close event""" ======= END EXAMPLE ============ and also, look at Chris Pearsons site: http://www.cpearson.com/excel/vbe.htm HTH Philip "JJ" wrote: How can I write a code from procedure to some Workbook's ThisWorkbook? With procedure1 a make Workbook with a table. I need to write Auto_Close procedure to ThisWorkbook which makes some controls before I close it. Is it possible? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
could someone write me a VB code? thanks | New Users to Excel | |||
write macro code | Excel Worksheet Functions | |||
Write a code by code | Excel Discussion (Misc queries) | |||
How can i write TSR code | Excel Programming | |||
Using VBA to Write VBA code | Excel Programming |