Error 1004 when trying to use .SaveAs in C: \ Users \ Me \ ProjectOutput

If the parameter is Excel_Default_Pathset to C: \ ProjectOutput, the following code works fine. But if the parameter is Excel_Default_Pathset to C: \ Users \ Me \ ProjectOutput, this happens with error 1004 . In addition, the object appExceldoes not have problems reading from the same directory in any case.

DefaultOutputFilenameset to AA1FS-7_VE8GUS_ED.xls and fmtgets the correct type. However, just put it in the "User" directory.

A bit more information. If I exit the VB application and select the open Excel application. I can directly save the modified book to C:\Users\Me\ProjectOutputwithout any problems.

In addition, this error occurs on my machine, as well as on another machine. On another machine, Excel_Default_Pathset to C: \ Users \ JSS \ ProjectOutput

    Dim fmt As Excel.XlFileFormat = GetExcelFileFormatForExtension(fi)
    appExcel.ActiveWorkbook.SaveAs(CStr(Excel_Default_Path & "\" & DefaultOutputFileName), fmt)
+4
source share
1 answer

I solved the problem. Excel_Default_Pathactually had a trailing "\" at the end. So this caused error 1004. Deletion \ from the variable is fixed.

+1
source

All Articles