LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using VBA to Write VBA code

Stuart,

I've been wrestling with this exact same problem. What I
found is that the code from the book always write the code
routine to Sheet1. If you have a multi-sheet workbook,
this is not what you want. What worked for me is the
following line of code:

With ThisWorkbook.VBProject. _
VBComponents(NewSheet.CodeName).CodeModule
NextLine = .CountOfLines + 1
.InsertLines NextLine, Code
End With

It seems that .CodeName is the correct reference.

--Frank

-----Original Message-----
I have John Walkenbach's book "Excel 2002 Power

Programming with VBA"
and was using the section entitled Using VBA to Write VBA

code (pg
797). Unfortunately the code I have entered is not

working and I
think it is because of the fact that I have excel 2000

(but I'm not
sure). The line of code which is causing the error is the

first one in
the following section

With ActiveWorkbook.VBProject. _
VBcomponents(shtNewNotesSheet.Name).CodeModule
nextline = .CountOfLines + 1
.InsertLines nextline, Code
End With

(where nextline is a numeric variable (dim as double) and

where Code
is a string variable which contains the VBA code I wish

to insert into
the worksheet)

Is the "VBComponents()" element a new property of the

VBProject object
(ie in excel 2002 but not excel 2000)??

If so how can I use VBA to write VBA in excel 2000?

Thanks in advance
.

 
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
could someone write me a VB code? thanks Morgan New Users to Excel 6 March 10th 10 01:20 PM
write macro code nishkrish Excel Worksheet Functions 0 April 2nd 09 09:17 PM
Macro to write code aftamath77 Excel Discussion (Misc queries) 3 October 8th 08 10:36 PM
Trying to write vba code to import another spreadsheet... joep3 Excel Discussion (Misc queries) 3 September 6th 06 06:50 PM
Write new VBA code from within a MACRO Neil Bhandar[_2_] Excel Programming 1 January 8th 04 04:16 PM


All times are GMT +1. The time now is 06:16 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"