Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Excel - opening with a password

$
0
0
Hi,

I have a small application that uses an excel file to store data. At this point my excel file does not have a password but I would like to set one and I am bit lost - so that users do not have access to open the file other than through my application (I am okay to hardcode the password). Since im using the following code to open and write to the file - appreciate your help with this - excuse the terrible programming skills and borrowed code... :)

Also at no point do i want the users to see the excel file opening and all that - ideally if all of this can be done without the users seeing the fiel opening and all that it would be great - I was trying to avoid using the SEND fucntion.

[ autoit ]         
GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $SaveButton GUISetState(@SW_DISABLE, $WinMain) ; Stops you from changing anything $FileName=@ScriptDir & "\Worksheet1.xls" if not FileExists($FileName) then ; Just a check to be sure.. Msgbox (0,"Excel Data Test","Error: Can't find file " & $FileName) Exit endif $oExcelDoc = ObjGet($FileName) ; Get an Excel Object from an existing filename If (not @error) and IsObj($oExcelDoc) then ; Check again if everything went well $iRowCount = $oExcelDoc.ActiveSheet.UsedRange.Rows.Count $iRowCount = $iRowCount + 1 $oExcelDoc.saved=1 ; Prevent questions from excel to save the file $oExcelDoc.close EndIf WEnd

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>