Macro to save file in shared network drive

Dscalf1

New Member
Joined
Jun 14, 2015
Messages
41
I am trying to get this file to be saved in a network drive mapped on my computer. I just want to save it and not close out the file or anything. What I have so far is listed below. I want the file name to be "Bread Reconciliation" + "Whatever date that is listed in cell D1 on Sheet "Bread Input" ". I keep getting this error: Run-time error'1004': Method 'SaveAs' of object'_Workbook' failed

Code:
Private Sub CommandButton1_Click()


Dim FP As String, FN As String
FP = "R:\Manufacturing Transformation\Wrap Reconciliation\Bread Archive\"
FN = Sheets("Bread Input").Range("BD1").Value
ActiveWorkbook.SaveAs Filename:=FP & FN & ".xls"
End Sub
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Code:
Private Sub CommandButton1_Click()


Dim fName1 as String
fName = Sheets("Bread Input").Range("Bread Input!BD1").Value
ActiveWorkbook.SaveAs Filename:="R:\Manufacturing Transformation\Wrap Reconciliation\Bread Archive\" & fName & ".xls"
End Sub

Try that and see how it does
 
Upvote 0
Code:
Private Sub CommandButton1_Click()


Dim fName1 as String
fName = Sheets("Bread Input").Range("Bread Input!BD1").Value
ActiveWorkbook.SaveAs Filename:="R:\Manufacturing Transformation\Wrap Reconciliation\Bread Archive\" & fName & ".xls"
End Sub

Try that and see how it does

Nope now its giving me a Compile Error: Syntax Error
 
Upvote 0
It may be because i left that 1 in there on the dim fName1. Try taking that out
 
Upvote 0
I had taken the 1 out previously and thats what I got. The line that comes up in red is the:

ActiveWorkbook.SaveAs Filename:=R:\Production\Wrap Reconciliation\Bread Archive" & fName & ".xls"
 
Upvote 0
I was missing a " in that path I fixed that so the syntax error went away. Now im getting this error:

Run-time error '1004':
Method 'Range of Object'_Worksheet' failed
 
Upvote 0
Try putting a space between the = and "R
Code:
[COLOR=#333333][I]Private Sub CommandButton1_Click()[/I][/COLOR]

Dim fName as String
fName = Sheets("Bread Input").Range("Bread Input!BD1").Value
ActiveWorkbook.SaveAs Filename:= "R:\Manufacturing Transformation\Wrap Reconciliation\Bread Archive\" & fName & ".xls" 
[COLOR=#333333][I]End Sub[/I][/COLOR]

Also are you using excel 97-2003 version? If not i wonder if the xls format is making it have problems
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,905
Messages
6,175,297
Members
452,633
Latest member
DougMo

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