I have a illogic code that run on save .. but for some reason a lot of files get save even if I do not have the files check out. I want to make sure that it does not run part on my Ilogic code if I do not have the file check out.
Files that I do not have check out usually is read only locally... is there a way to get the info form the vault or the files attribute so I can force it not to run part of my illogic code ?
Easiest way would be to query file attributes rearrange the code depending on whether it's read-only or not (assuming read-only status matches check in/out status):
If (GetAttr(file_path) And vbReadOnly)>0 Then MsgBox("checked out") Else MsgBox("not checked out") End If
The only dim missing is for whatever variable has your file path string. All you should have to do if rearrange your existing code to match the if statement:
Dim file_path as string
file_path = "your_file_path"
If (GetAttr(file_path) And vbReadOnly)>0 Then 'copy the code you want to run if file is read only here Else 'copy the code you want to run if file is not read only here End If
he is referring to the system.io method of getting/setting file attributes
dim fi as new system.io.fileinfo("c:\FullFilePath\With\File.Ext")
System.IO.File.SetAttributes(fi.FullName, System.IO.FileAttributes.Normal)
system.io.file.GetAttributes(fi.FullName) as FileAttributes
This is actually a risky method to determine if the file is checked out, because occasionally (not by design), a vaulted file will be checked out, but still have the readonly attribute set.
iLogic recognizes GetAttr() without needing to explicitly go through System.IO, but that certainly works as well. Agreed that reading the file state is not a very robust solution, but it may work well enough here.
For sure its better than 1. nothing, and 2. learning the vault professional API.
done with vba should be possible with ilogic as well:
Can't find what you're looking for? Ask the community or share your knowledge.