Jump to content

Recommended Posts

Posted (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 by danusko
Posted

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.

:P

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
Posted

thank you very much

its works perfect :P

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

Posted (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

:P

Edited 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
Posted (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

:mellow

i 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 by danusko
  • 5 years later...
Posted

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
Posted

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 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...