![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Hi everyone...
In reference to this topic: http://www.mrexcel.com/board/viewtop...5978&forum=2&2 I am trying to import a text file into a VBA project... The text file would be in the activeworkkbook path and named DeleteOld.txt Thanks for any help, Tom |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Jay gave this guy a solution, but I would still like to know how to import a text file into a VBA project if possible...
Thanks again, Tom |
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Kobe, Japan
Posts: 1,420
|
Hi TsTom. You mean like this?
Sub Test() With ActiveWorkbook.VBProject .VBComponents.Import FileName:=ActiveWorkbook.Path & "DeleteOld.txt " End With End Sub |
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Kobe, Japan
Posts: 1,420
|
Please modify the character "" in code.
mean chr(&H5C). I could not input the character from my pc. |
|
|
|
|
|
#5 | ||
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Thanks Colo
One further question... In the following code, how might I get around the compile error? The following will load TestImport.bas dynamically.... Quote:
Quote:
I get an obvious compile error with the call to "TestRun" because the module containing the procedure does not exist in the project until it is loaded. I checked into Conditional Compilation and it did not seem to be what I needed... Any other ideas? Thanks again, Tom |
||
|
|
|
|
|
#6 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Kobe, Japan
Posts: 1,420
|
Hello again! In this case, I always use "OnTime Now"
Pls try this. Sub TryImport() With Application .VBE.ActiveVBProject.VBComponents.Import "C:TestImport.bas" .OnTime Now, "TestRun" End With End Sub Regards, Colo |
|
|
|
|
|
#7 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Thanks Colo,
Works perfectly. Tom |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|