Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Code Steph Excel Worksheet Functions 0 February 27th 10 06:08 PM
How to insert code Karl Excel Discussion (Misc queries) 3 January 8th 07 11:01 PM
Insert Code Derek Y via OfficeKB.com New Users to Excel 3 October 17th 05 03:48 AM
code to insert add'l code ??? mark kubicki Excel Programming 1 August 16th 04 10:37 PM
Insert into existing code gav meredith Excel Programming 0 April 21st 04 02:43 AM


All times are GMT +1. The time now is 12:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"