VBA Method 'Save As' of object'_Workbook@ failed

Snnnider

New Member
Joined
Jul 21, 2015
Messages
7
Hello again forum, I posted earlier about a project I was undertaking and was wondering if anyone could help again please

I am creating multiple workbooks, using a loop and pasting data into each of them in turn and saving them. Every now and again I get an error message pop up on screen

" Run-time error '1004': Method'SaveAs'of object'_Workbook' failed"

Though it doesn't always do it, and I can not find a common denominator as to why, the code I am using to save each file is as follows:

Code:
Workbooks.Add
    ActiveSheet.Paste
    Supplier = Range("B2").Text
    ActiveWorkbook.SaveAs Filename:="H:\invoiceMacroWork\Suppliers\" & Supplier & ".xlsx"
    ActiveWorkbook.Close True
    Set rng = Nothing
    Next i
"

I have read somewhere that ActiveWorkbook.Saveas could be the problem, but as I have nearly 190 different files to save it would be difficult for me to name each and every one.

Has anyone encountered this before?

My prior thread to give some context:
http://www.mrexcel.com/forum/excel-questions/869688-if-two-cells-equal-mark-unique.html
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
The workbook I am copying the data from has a macro, however the data I am copying to would not be a macro enabled workbook, the workbook I am copying to is the one i want to save
 
Upvote 0
I think the save as name is incorrect, I would test to see if the path exists or verify some other way that you are saving to the correct folder.
 
Upvote 0
I thought this too

However I am running the loop 190 times, and a lot of them will save, however sometimes they do not. But it is not usually on the same file number each time, it generally changes each time. So I am finding it difficult to track as to why, so I'm thinking its an excel issue not my data
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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