danusko Posted March 11, 2009 Share Posted March 11, 2009 (edited) Hi all, please i use Autoit 3.0.100. I want use this vs. Can i check with autoit, if is xls file open (is read-only) and if not, so overwrite this file with a new one. Or need i the excel.au3 file wich is in INCLUDE folder? thx this doesnt work. $file = FileOpen('"y:\1220\A\B\C\file.xls"', 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileCopy('"c:\1220\auto\cat\file.xls", "y:\1220\A\B\C\*.*"',1) Edited March 11, 2009 by danusko Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 11, 2009 Share Posted March 11, 2009 Hi all, please i use Autoit 3.0.100. I want use this vs. Can i check with autoit, if is xls file open (is read-only) and if not, so overwrite this file with a new one. Or need i the excel.au3 file wich is in INCLUDE folder? thx this doesnt work. $file = FileOpen('"y:\1220\A\B\C\file.xls"', 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileCopy('"c:\1220\auto\cat\file.xls", "y:\1220\A\B\C\*.*"',1) Before you try the copy, attempt to open the file for write (close it again without writing anything, of course). If the FileOpen() for write fails, you have your answer. If you want to check specifically for Excel having the file open, then you could attempt _ExcelBookAttach() using the full file path, and if it fails then Excel does not have the file open. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
danusko Posted March 11, 2009 Author Share Posted March 11, 2009 thank you very much its works perfect Link to comment Share on other sites More sharing options...
danusko Posted March 11, 2009 Author Share Posted March 11, 2009 thank you very muchits works perfect sorry, one more questionif i want to check, if the file in destination folder exist and if YES, than copy the file with the same name + date in format DDMMYYso if the name is "file", it will copy as file110309.xlshow can i do this?thx a lot Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 11, 2009 Share Posted March 11, 2009 (edited) sorry, one more question if i want to check, if the file in destination folder exist and if YES, than copy the file with the same name + date in format DDMMYY so if the name is "file", it will copy as file110309.xls how can i do this? thx a lot Use the Date macros, though I suggest reformatting so the dates will automatically sort by _YYYYMMDD: $sDestination = "file" & "_" & @YEAR & @MON & @MDAY & ".xls" This example would be: file_20090311.xls Edited March 11, 2009 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
danusko Posted March 11, 2009 Author Share Posted March 11, 2009 (edited) Use the Date macros, though I suggest reformatting so the dates will automatically sort by _YYYYMMDD: $sDestination = "file" & "_" & @YEAR & @MON & @MDAY & ".xls" This example would be: file_20090311.xls :mellowi don know if i understund i try this with using your advise..but doesnt works [quote]#include "C:\Documents and Settings\aaa\docs\programs\autoit3\Include\date.au3" $sDestination = "file" & "_" & @YEAR & @MON & @MDAY & ".xls" $file = FileCopy("C:\P\a.xls", "C:\P\aa\*.*",0) ; FileCopy("C:\P\a.xls", "C:\P\aa\*.*",0) If $file = 0 Then MsgBox(0, "ERROR", "Not good") Exit EndIf ToolTip("OK", 350, 200) Sleep(3000) Edited March 11, 2009 by danusko Link to comment Share on other sites More sharing options...
danusko Posted March 11, 2009 Author Share Posted March 11, 2009 i´ve got it it works good thx very much Link to comment Share on other sites More sharing options...
raine Posted May 15, 2014 Share Posted May 15, 2014 Opened Excel file have ~$filename.xlsx at the folder, check if the file not exist. #include <file.au3> Local $ExcelFilePath = "D:\Data\Office\Excel\Accounts.xls" Local $checkExcel = StringSplit($ExcelFilePath,"\"); split file path with delimiter of "\" Local $tempExcel = $checkExcel[1] For $enumtemp = 2 to Ubound($checkExcel)-2 $tempExcel = $tempExcel & "\" & $checkExcel[$enumtemp] Next $tempExcel = $tempExcel & "\~$" & $checkExcel[Ubound($checkExcel)-1]; construct new filename of temporary file excel at the same specified directory, the file have prefix ~$ at the filename While FileExists($tempExcel); check if the temporary file exist, delay here as long as the temporary file exist Sleep(10000) WEnd ;Do what you want to do with excel file, it's free now Link to comment Share on other sites More sharing options...
water Posted May 15, 2014 Share Posted May 15, 2014 Welcome to AutoIt and the forum! You posted to a 5 years old thread. Do you think anyone is still interested in a solution Please do not necro old posts. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now