How can I check if the Excel file is open for editing from a script?
I have a script that runs a PowerPoint presentation.
Powerpoint at some point in the script opens, and updates the links in it (the source data is an Excel Spreadsheet)
Now if the source Excel file is open for editing by someone then PowerPoint can’t update the links and the script gets confused.
How can I check if the Excel file is open from the script and thus make the script to tell Powerpoint not to update?
Thanks
Mabel
How to Test if an Excel File open in a script
Re: How to Test if an Excel File open in a script
Do a fileMove on the excel file. If errorlevel is > 0 then you could assume that it failed because it is open.
Re: How to Test if an Excel File open in a script
thank you
i will give that a go
i will give that a go
Re: How to Test if an Excel File open in a script
thanks that works.
pity there wasn't a is file open function.
thanks again
pity there wasn't a is file open function.
thanks again
Re: How to Test if an Excel File open in a script
Code: Select all
IsFileInUse(FileName) {
return FileExist(FileName) && !FileOpen(FileName, "rw")
}
Re: How to Test if an Excel File open in a script
slightly clunky excel com object approach...
Code: Select all
wb := A_Desktop "\Book1.xlsx"
if ( IsWorkbookOpen( wb ) = true )
{
msgbox workbook is open!
return
}
IsWorkbookOpen( wb )
{
xlObj := ComObjCreate( "Excel.Application" ), xlObj.WorkBooks.Open( wb )
ReadOnly := xlObj.ActiveWorkbook.ReadOnly, xlObj.Quit
return !ReadOnly ? 0 : 1
}
folded
tested/works here..Re: How to Test if an Excel File open in a script
thank you.
I was searching for things like file open and other things with open in the title.
i didn't think about using the "use"
silly me.
i will follow through on the way the function works. thanks
still at the start of the learning curve.
thanks for the help
I was searching for things like file open and other things with open in the title.
i didn't think about using the "use"
silly me.
i will follow through on the way the function works. thanks
still at the start of the learning curve.
thanks for the help