Importing *.txt file, macros stop

Skyhawk32806

New Member
Joined
May 8, 2010
Messages
26
I was looking around but I can't find a solution to this one...

I have another program that writes out a .txt file. I then have a macro to open the file, and then run some macros on it. However as soon as the .txt file is opened in Excel the macros stop running, without any error messages.

It looks like when the txt file is opened it, ALWAYS opens with Design Mode selected. Please see below for a snippit of my code...

Code:
Sub Macro2()
'
    'Open the text file, this part works
    Workbooks.OpenText Filename:= _
        "C:\My File.txt", Origin:=437, _
        StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1), Array(10 _
        , 1), Array(51, 1), Array(69, 1)), TrailingMinusNumbers:=True
      'Everything after this point will not run.
End Sub

I ended up using...

Code:
Workbooks.Add "C:\My File.txt"

The secound meathod seems to work, however I can't seem to get the text import wizard to invoke.

So I guess my question is, how do I open the text file with the Text Import Wizard and continue to run the macro after that? I'm not sure what I'm missing here. :confused:

Thanks everyone!!
 

Some videos you may like

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Watch MrExcel Video

Forum statistics

Threads
1,122,962
Messages
5,599,065
Members
414,281
Latest member
Engjamal2021

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