Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert a .bas in excel when opening a file. 2

Status
Not open for further replies.

bluelive

Programmer
Oct 21, 2003
8
BE
Hi,
Anybody knows how to write a vba code to insert a .bas file into the actual opened workbook ? From the VBAProject, I can use the file menu to import a .bas file. A would like to do the same but with the help of vba code.

Flow process:

1. Open a xls file
2. Execute a procedure to importe the .bas file
3. Execute the code inserted when quitting Excel.

Thank to all.
=> writted example is better if possible.

 
You can use:
[tt]ThisWorkbook.VBProject.VBComponents.Import ("c:\vbfile.bas")
Run ("yourProcName")[/tt]

Note that there are some limitation in passing arguments to a macro run this way. You can get virus alert by some AV programmes, and the access to VBA project can be blocked (in XP).

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top