Workbooks close syntax error

Daniel Duhaime 20 Reputation points
2023-03-30T13:28:00.6033333+00:00

Trying to save a modified spreadsheet within access VBA does not work

Code sample:

Output_File = "c:\temp\test.xlsx"

xlApp.workbooks.Open (Temp_File) ***Work no problems

With xlApp.Worksheets("Sheet1") ***Work no problems

.Range("A1).Value = "Spreadsheet title" ***Work no problems

end with

xlApp.workbooks.Close SaveChanges:=TRUE, Output_File *** Syntax error

What should be the syntax for this command to execute without problems

I also try xlApp.workbooks.Close (TRUE, Output_File) *** syntax error

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,668 questions
Excel Management
Excel Management
Excel: A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.Management: The act or process of organizing, handling, directing or controlling something.
1,689 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 114.7K Reputation points
    2023-03-30T14:02:39.8666667+00:00

    Try something like this:

    Dim wb As Workbook
    Set wb = xlApp.Workbooks.Open(Temp_File)
    . . .
    wb.SaveAs Output_File
    wb.Close
    xlApp.Workbooks.Close
    xlApp.Quit
    
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful