2
votes

I had Excel record the steps of choosing Save As and applying a specific location and file name, and it produces this VBA code:

 ActiveWorkbook.SaveAs Filename:= _
    "H:\Documents\Data\Tasks\Transfer.xlsx" _
    , FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False

Have also tried setting the FileFormat as

FileFormat:=51

I also included the following handlers, but it doesn't work with or without them:

On Error Resume Next
Application.DisplayAlerts = False

The original file is in .xls format.

When I run the macro allowing display alerts, it produces this error:

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

This used to work until I believe going to Windows 8 and a new network server at work. Could something like that affect SaveAs?

What am I missing? Thanks for any tips you might have.

1
Does it work if you change the mapped drive (H) to a UNC, e.g., \\Server\Documents ... ? - Doug Glancy
Yes, I am able to manually able to save these .xls files as .xlsx. Good point about UNC. Sometimes the macro recorder would produce that too depending on location, so I had tried that both ways. - Rusty S.

1 Answers

0
votes

Try this

Application.ActiveWorkbook.SaveAs Filename:="H:\Documents\Data\Tasks\Transfer.xlsx", fileformat:=51