Save File Macro ERROR

nathanpeattie

New Member
Joined
Dec 17, 2005
Messages
43
this is my code

Sub macro1()

FileID = InputBox("Type The PO Number To Be Saved")
ActiveWorkbook.SaveAs Filename:= _
"C:\Montford\Quotes\Customers\" & FileID & ".xls", FileFormat _
:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

End Sub

if I click cancel in the diaglog box it get

Runtime Error "1004"

Method 'SaveAs' of object '_Workbook' Failed

and I get End And Debug (How to fix?)

Thanks
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Perhaps this.
Code:
Sub macro1() 

FileID = InputBox("Type The PO Number To Be Saved") 
If FileID<>"" Then
     ActiveWorkbook.SaveAs Filename:= _ 
"C:\Montford\Quotes\Customers\" & FileID & ".xls"
End If
End Sub
 
Upvote 0
Thanks that worked great.

The next thing I need is a find code. As you can see I save the workbook as a PO number eg: 12345.xls I need a code that when I click a button it will find PO number files.

EG: A dialog box will open and ask the user to type in the PO number they want to find. The user will input the po number and click ok. The code will then find the file with the po number and open it.

All the files will be in the same location I will not need the code to search the whole drive just 1 location.

Thanks
 
Upvote 0
nathan

Could you please try and keep to one thread?

As far as I can see all your posts so far are related.
 
Upvote 0
Yes I probably can, but I seem to remember that in another thread somebody has made some suggestions.

Like I said try and keep to 1 thread.

I've read most of your posts and have now become confused as to what stage you are currently at.

Are you not getting a bit confused yourself?:)
 
Upvote 0
I have read those suggestions and I have one of them as my open origanl file code.

The find code is the last code I am working on and then the project to done.

If I have missed a suggestion can you post the location of that post

Thanks
 
Upvote 0
Try this:
====================================
Sub GetFile()
NewFN = Application.GetOpenFilename(filefilter:="Text Files(*.xls),*.xls,All Files (*.*),*.*", Title:="Please select a file")
If NewFN = False Then
' They pressed Cancel
MsgBox "Stopping because you did not select a file"
Exit Sub
Else
Workbooks.Open Filename:=NewFN
End If
End Sub
===================================
It won't "Search" for a PO #, but since they know the PO # and have saved the file with that name, typing the PO # in the file Name section in the "Open" dialog will open that file.
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,214
Members
449,074
Latest member
cancansova

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