• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro File Saving Issue

JeetuJoshi

New Member
Hello All, i have created one macro in which i am copying data in new excel sheet from working sheet and saving that using cell reference but facing issue in some files :
Method saveas'of object'_workbook' failed

Save file macro code is - wb2.saveas filename:=fname, fileformat: = xlworkbookdefault

plz help me this is very urgent for me
 
Hi there,
Check whether you have assigned an object to your wb2 variable.

>>> use code - tags <<<
Code:
Sub test()
    Dim wb2 As Workbook
    fname = "D:\sample"
    Set wb2 = ThisWorkbook   'Check this line
    wb2.SaveAs Filename:=fname, FileFormat:=52
End Sub
 
Last edited by a moderator:
Hello, thanks for your help but i am still getting same error, my macro is working in some file but in some files it is showing error while saving.
 
Save file macro code is - wb2.saveas filename:=fname, fileformat: = xlworkbookdefault

There is nothing wrong with this line of code
Code:
wb2.SaveAs Filename:=fname, FileFormat:=xlWorkbookDefault

But whether it works or not depends the values of variables wb2 and fname. In other words you have not posted enough information for a reader to understand your problem.
 
Back
Top