Philippe Fassin
Philippe Fassin

Reputation: 1

run-time error '1004' application-defined or object-defined

I'm working on a file for HR, to keep track of the start- and end times of employees. I get their name and required hours, and want to open a save as dialog to save the file using the name of the employee so the HR department only has to open the template and fill in the data and save, all in one fluid motion. I made a sub for all of this and it works nice, but after the save location has been defined, I get a run-time '1004' application-defined or object-defined error.

If ThisWorkbook.BuiltinDocumentProperties("title") = "" Then
strTitle = "Timesheet " & UCase(strNaam) & " " & StrConv(strVoornaam, 3)
varDirectory = Application.GetSaveAsFilename(strTitle, "Timesheet Files(*.xlsm), *.xlsm")
Sheets("Data").Range("B25") = varDirectory

ActiveSheet.SaveAs Filename:=varDirectory, FileFormat:=25 ------------> error
ThisWorkbook.BuiltinDocumentProperties("title") = strTitle

End If

Basically it changes the title of the file to something, and prompts a dialog to choose the location which it then writes in a cell (not ideal, but it's nice workaround).

I get the error on the second to last line.

Upvotes: 0

Views: 171

Answers (1)

SierraOscar
SierraOscar

Reputation: 17647

25 is an International Macro format.

You want 52, which is Open XML Macro Enabled.

You can also use the xlFileFormat enumeration:

ActiveSheet.SaveAs Filename:=varDirectory, FileFormat:=xlOpenXMLWorkbookMacroEnabled

Upvotes: 1

Related Questions