Jump to content

Variable in a string question


Recommended Posts

Mhz,

Do you know how I can wait for an excel spreadsheet to finish saving before I end the process.

I am trying to do these two things, but they are not working.

The second bit of code will work, but I dont want to set a sleep time, because some files may take longer to save than other.

Thanks.

1-----------------------------------------------------------------------

WinWaitNotActive("Microsoft Excel - " & $duplicate_report_name & ".xls")

$PID10 = ProcessExists("EXCEL.EXE")

If $PID10 Then ProcessClose($PID10)

----------------------------------------------------------------------

2----------------------------------------------------------------------

While $click_flag1 = 0

If WinGetTitle("Microsoft Excel - " & $duplicate_report_name & ".xls", "") = 1 Then

$click_flag1 = 1

Sleep(1500)

$PID10 = ProcessExists("EXCEL.EXE")

If $PID10 Then ProcessClose($PID10)

Endif

WEnd

---------------------------------------------------------------

Link to post
Share on other sites

COM is supported in the beta and looking through the Excel COM, I see there is a property of the WorkBook class:

Saved (Boolean): Gets or sets the saved state of the workbook. If the user has made modifications to the workbook's contents or structure, the Saved property is True. Attempting to close the workbook or quit Excel will cause an alert to appear, prompting you to save the workbook (unless you've set the Application.DisplayAlerts property to False). If you set the Saved property value to False in your code, Excel will treat your workbook as if it had already been saved, and not prompt you to save it again.

Don't know if that can be of any use to you. Here is the full article:http://msdn.microsoft.com/library/default....ml/ExcelObj.asp

AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
Link to post
Share on other sites

Mhz,

Do you know how I can wait for an excel spreadsheet to finish saving before I end the process.

The following code looks for the word "Ready" to appear on the status bar of the Excel screen and waits until it sees it to move on to the next command. It's ugly, but it works for McAfee AV and Defrag. You need to replace "yourfilename" with the variable that you are already using, plus you need to find the exact location where StringInStr finds "Ready" on your Excel screen. Replace the XX that I put in the code with your value. The While loop will keep running until it sees "Ready" at that location in $text.

dim $text = ""
; Initialize $text
$text = WinGetText("Microsoft Excel - yourfilename","")
       
; Keep checking $text to see if "Ready" exists in it
While StringInStr($text,"Microsoft Excel - yourfilename") <> XX; XX is the 
           numeric location where you find "Ready" on a dry run of StringInStr
; Read $text again
$text = WinGetText("Microsoft Excel - yourfilename","")
;MsgBox(0, "Value of $text is:", $text) ; for debug
WEnd
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to post
Share on other sites

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...