From Friday, January 17th 11 PM CDT (January 18th 5 AM UTC) through Saturday, January 18th 11:30 AM CDT (January 18th 5:30 PM UTC), ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

check if excel file open

Solved!
Go to solution

Hallo,

 

how can i check if a excel file is open or not open. I need a code for the diadem script.

 

thanks

0 Kudos
Message 1 of 3
(3,499 Views)
Solution
Accepted by topic author Joediadem

You can use code like this to make sure that a file is accessible exclusively.

 

Option Explicit

dim xlsxFile : xlsxFile = "C:\temp\out_EXPORT.xlsx"
MsgBox FileAccessible(xlsxFile)

function FileAccessible(byref filePath)
  FileAccessible = FALSE
  dim fh : fh = TextFileOpen(filePath, eTextFileAttributeExclusive OR eTextFileAttributeRead OR eTextFileAttributeANSI)
  if -1 <> fh then
    call TextFileClose(fh)
    FileAccessible = TRUE
  end if
end function
0 Kudos
Message 2 of 3
(3,490 Views)

perfect, thank you

0 Kudos
Message 3 of 3
(3,467 Views)