Run-Time Error 1004

daviho

New Member
Joined
Aug 30, 2017
Messages
3
I have a file that uses an active x control box to save the file into two locations. The code is as follows:
Code<<Sub SaveToLocations()'UpdateByExtendoffice20160623
ActiveWorkbook.SaveCopyAs "A:\PAULA & RUTH\CAPITAL ASSETS" + ActiveWorkbook.Name
ActiveWorkbook.SaveCopyAs "P:\Rail Car Inventory\Capital Project" + ActiveWorkbook.Name
ActiveWorkbook.Save
End Sub>>

The error occurs when I try to save the file when it was opened from the second location.

Any suggestion on how to allow saving to occur from either location and update the other?
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Did you not need a backslash character after Assets and Project? & is the concatenation character, not +.

FileFormat may need to be set as the second parameter but is usually only a problem when saving to other format than copy.
Code:
activeworkbook.fileformat
 
Upvote 0
Thanks Kenneth,

I've made the changes suggested but I still get the same result. The primary location will save to both, but the secondary will receive the run-time error I've even tried to list both as .fileformat. This will update both when the file is opened with the primary location but only the secondary location when utilizing the secondary file location. Would you have any other suggestions?

Code:
Sub SaveToLocations()'UpdateByExtendoffice20160623
    ActiveWorkbook.SaveCopyAs "A:\PAULA & RUTH\CAPITAL ASSETS\" & ActiveWorkbook.FileFormat
    ActiveWorkbook.SaveCopyAs "P:\Rail Car Inventory\Capital Project\" & ActiveWorkbook.Name
    ActiveWorkbook.Save
End Sub
 
Upvote 0
Why not save the file first? That way, your file will have a name with a file extension. You might want to make sure that you want the ActiveWorkbook saved, and not ThisWorkbook.

Of course A: drive is typically a floppy drive which many don't have anymore. P: would be a network drive or a virtual drive. I guess we could check if those two folders exist before using Dir() or Scripting.FileSystemObject. Of course you know your setup better than us so if you know they exist, there is no reason to check.

Code:
Sub SaveToLocations() 'UpdateByExtendoffice20160623
  With ActiveWorkbook
    .Save
    .SaveCopyAs "A:\PAULA & RUTH\CAPITAL ASSETS\" & .Name
    .SaveCopyAs "P:\Rail Car Inventory\Capital Project\" & .Name
  End With
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,318
Members
452,634
Latest member
cpostell

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