Saving a new (imported) file

micahs_10

Board Regular
Joined
Sep 2, 2004
Messages
83
Hello,
I've been working through this macro all day (with the help of the board) and I'm almost there. The macro opens a text file (into a new workbook) and performs a lot of formatting on the file. I'm now trying to get the macro to ask the user to SaveAs, but I keep getting a "Method 'SaveAs" of object '_Workbook failed". Below is the beginning and end of the macro (basically the opening the text file and close the excel file portions). Please let me know if I should post more of the code. Thanks!

Beginning
Code:
    TextFileName = Application.GetOpenFilename _
    ("Text Files (*.txt), *.txt", , "Select File", , False)
    Workbooks.OpenText Filename:= _
        TextFileName, Origin:=437, _
        StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 2), Array(8, _
        2), Array(39, 1), Array(45, 1), Array(68, 1), Array(88, 1), Array(108, 1), Array(148, 1), _
        Array(155, 1), Array(178, 1), Array(198, 1), Array(218, 1), Array(238, 1), Array(245, 1), _
        Array(268, 1), Array(288, 1), Array(308, 1), Array(328, 1), Array(335, 1), Array(358, 1), _
        Array(378, 1), Array(398, 1), Array(418, 1)), TrailingMinusNumbers:=False

End of Macro
Code:
    SaveFileName = Application.GetSaveAsFilename _
    ("Excel Files (*.xls), *.xls", , "Name This File", , False)
    
    ActiveWorkbook.SaveAs Filename:=SaveFileName

Not sure what the problem is..any help is greatly appreciated.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
I'd take a closer look at the GetSaveAsFilename Method. The arguments are similar, but not the same as the GetOpenFilename Method.
 
Upvote 0

Forum statistics

Threads
1,207,280
Messages
6,077,506
Members
446,287
Latest member
tjverdugo85

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
Back
Top