Opening data file

jpen

Active Member
Joined
Jun 19, 2002
Messages
394
Hi all,

I have a directory with data files (txt format) which I import in Excel. Now I want to start a macro at the moment I select one of these files. How can I do this??

Thanks
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

ChrisUK

Well-known Member
Joined
Sep 3, 2002
Messages
675
Why not use your macro to open the file then call the macro you want directly afterwards.

To open a file for import then execute another macro afterwards use this code.

Workbooks.OpenText Filename:="C:Filesmyfile.txt", Origin:=xlWindows _
, StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(1, 1)

Call mymacro


Hope this helps
 

jpen

Active Member
Joined
Jun 19, 2002
Messages
394
The problem is that the filename in the macro is not a variabel. I have about 100 data files (all having another name) which I want to import in Excel.
 

Forum statistics

Threads
1,144,312
Messages
5,723,647
Members
422,508
Latest member
Lordkit1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top