Jump to content

Recommended Posts

Posted (edited)

I have price-list in xls. When I open it by _Excel_Open and _Excel_BookOpen and after that close by _Excel_Close, I have a message about "Save changes?"

I try open it in read-only mode, but no changes made. I still see annoing message.

Windows 10 prof, MS Office 2007.

 

#include <Excel.au3>
#include <MsgBoxConstants.au3>

ConsoleWrite(@AutoItVersion)

Global $sPriceFile = @ScriptDir&"\opt_pr_list-mini.xls"

Local $oExcel = _Excel_Open(False, False, False, True) 
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

Local $oWorkbook = _Excel_BookOpen($oExcel, $sPriceFile, True )     ; readonly
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead", "Error opening workbook @error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

_Excel_Close($oExcel, False, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Close Example 2", "Error closing the Excel application." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

Exit

What I do wrong?

Thanks.

opt_pr_list-mini.xls.zip

Edited by Sergy
Posted

i've not tested it as not near my computer but are you sure its not closing it by the @Error  where no parameters are set?

_Excel_Close($oExcel)
Posted (edited)
6 minutes ago, joboy2k said:

i've not tested it as not near my computer but are you sure its not closing it by the @Error  where no parameters are set?

_Excel_Close($oExcel)

Then I have _Excel_Close @error: 3 - Error returned by method Application.Save. @extended is set to the COM error code

And still see Excel message.

Edited by Sergy
Posted

The Excel workbook contains macros plus links to other workbooks. So the workbook always gets changed after being opened.
 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

Thanks! I remove all options about readonly, use _Excel_BookClose ($oWorkbook) as autosave, and all works great!

Posted

:)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...