Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 142
Default Is there a way to read lines of a module

I would like for a VBA macro to be able to read the lines of one of its
modules as data so that the macro can do something with. Is that possible?

What follows is only a specific example. Suppose I have a module that
contains:
Public Const rName as String="MySheet!A"
Public Const rAddr as String="MySheet!B"
Public Const rDog as String="MySheet!C"
I would like the macro to beable to read the above 3 lines (along with
whatever else is in the module) and set row 1 (the column headers) of
MySheet to: Name, Addr, and Dog

Thanks for your help!

  #2   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Is there a way to read lines of a module

there is some information here that should help

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


" wrote:

I would like for a VBA macro to be able to read the lines of one of its
modules as data so that the macro can do something with. Is that possible?

What follows is only a specific example. Suppose I have a module that
contains:
Public Const rName as String="MySheet!A"
Public Const rAddr as String="MySheet!B"
Public Const rDog as String="MySheet!C"
I would like the macro to beable to read the above 3 lines (along with
whatever else is in the module) and set row 1 (the column headers) of
MySheet to: Name, Addr, and Dog

Thanks for your help!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Is there a way to read lines of a module

You can use code like

Dim S As String
With ActiveWorkbook.VBProject.VBComponents("Module2").C odeModule
S = .Lines(1, .CountOfLines) ' note leading periods
End With
Debug.Print S

This will put the contents of the entire Module2 into the variable S.

See also www.cpearson.com/Excel/VBE.htm .


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)

wrote in message
...
I would like for a VBA macro to be able to read the lines of one of its
modules as data so that the macro can do something with. Is that
possible?

What follows is only a specific example. Suppose I have a module that
contains:
Public Const rName as String="MySheet!A"
Public Const rAddr as String="MySheet!B"
Public Const rDog as String="MySheet!C"
I would like the macro to beable to read the above 3 lines (along with
whatever else is in the module) and set row 1 (the column headers) of
MySheet to: Name, Addr, and Dog

Thanks for your help!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 142
Default Is there a way to read lines of a module

Thanks! Works great!
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
How to read all lines from a text file into cells C10:Cxxx ? Claudia d'Amato Excel Discussion (Misc queries) 1 September 22nd 09 01:11 PM
Read Variable from Another Module Mike H. Excel Programming 2 August 27th 07 06:36 PM
Read lines from one worksheet, if value is true, write to new work Bernie Excel Discussion (Misc queries) 2 March 15th 07 11:27 PM
How to read CSV lines into different Worksheets depending on a date field? Markus Obermayer Excel Worksheet Functions 0 February 8th 06 11:23 PM
Lines in a Module(Procedure) Juan Melero Excel Programming 6 December 30th 03 12:38 AM


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