![]() |
Insert code by code
Dear All,
I create a new excel workbook from a template by using Selection.PasteSpecial so the code in the template is not copied. But i want some new code in the new workbook! Is it possible to insert code ( workbook_Before_close) in the new workbook. Filip |
Insert code by code
Hi
siehe: http://www.cpearson.com/excel/vbe.htm -- Regards Frank Kabel Frankfurt, Germany "Filips Benoit" schrieb im Newsbeitrag ... Dear All, I create a new excel workbook from a template by using Selection.PasteSpecial so the code in the template is not copied. But i want some new code in the new workbook! Is it possible to insert code ( workbook_Before_close) in the new workbook. Filip |
Insert code by code
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 -- HTH RP "Filips Benoit" wrote in message ... Dear All, I create a new excel workbook from a template by using Selection.PasteSpecial so the code in the template is not copied. But i want some new code in the new workbook! Is it possible to insert code ( workbook_Before_close) in the new workbook. Filip |
All times are GMT +1. The time now is 05:18 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com