Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Creating new VBA code on the fly

I am writing an Excel/VBA application in which it would be helpful
to construct a new VBA module 'on the fly," i.e, so
it could be used in the same application later. I've previously used
InsertLines to create an event procedure for a control button click
on a worksheet, so that is one possibility if I can figure out
the details. How would I indicate Which module to put it in?


Another possibility is to write the code to a file, then
import the file as a module. Is importing possible programmatically,
or only from the File menu in the VBA IDE?

TIA


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Creating new VBA code on the fly

Chip Pearson shows you how:

http://www.cpearson.com/excel/vbe.htm

--

Vasant


"Jag Man" wrote in message
...
I am writing an Excel/VBA application in which it would be helpful
to construct a new VBA module 'on the fly," i.e, so
it could be used in the same application later. I've previously used
InsertLines to create an event procedure for a control button click
on a worksheet, so that is one possibility if I can figure out
the details. How would I indicate Which module to put it in?


Another possibility is to write the code to a file, then
import the file as a module. Is importing possible programmatically,
or only from the File menu in the VBA IDE?

TIA




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Creating new VBA code on the fly

Sub test()
Dim wkb As Workbook

Set wkb = ThisWorkbook 'as an example

wkb.VBProject.VBComponents.Import "C:\T\Module2.bas"
End Sub


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Jag Man" wrote in message
...
I am writing an Excel/VBA application in which it would be helpful
to construct a new VBA module 'on the fly," i.e, so
it could be used in the same application later. I've previously used
InsertLines to create an event procedure for a control button click
on a worksheet, so that is one possibility if I can figure out
the details. How would I indicate Which module to put it in?


Another possibility is to write the code to a file, then
import the file as a module. Is importing possible programmatically,
or only from the File menu in the VBA IDE?

TIA




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
Creating charts with VBA code Ayo Charts and Charting in Excel 2 April 8th 09 12:08 PM
need help creating a Worksheet_Change code Cajun20th Excel Worksheet Functions 4 May 18th 06 09:12 AM
Creating Macro or Code Help? Jeni Q Excel Worksheet Functions 2 September 13th 05 02:29 PM
Creating a loop from my code Todd Huttenstine\(Remote\) Excel Programming 3 November 28th 03 04:05 PM


All times are GMT +1. The time now is 08:55 AM.

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

About Us

"It's about Microsoft Excel"