vtuls Posted June 5, 2013 Posted June 5, 2013 Hi guy's it's been a while since i needed some help but this is one strange cookie i'm writing a script that checks what language of Office is installed on a client, and im writing the information to an Excel sheet. expandcollapse popup; Tool t.b.v. Office pakket installatie ; controleer welke machine welke taal van Office geinstalleerd heeft. #include "Excel.au3" $dir = @ScriptDir if FileExists($dir & "\Settings.ini") Then $settings = $dir & "\Settings.ini" $Row = IniRead($settings,"Excel","Row","2") else $Row = 2 $settings = $dir & "\Settings.ini" EndIf $User_name = 0 $User_account = 0 $Machine_naam = 0 $Machine_Office = 0 $oexcel_exists = 0 ; 1: created new 2: existed if FileExists($dir & "\OfficeList.xls") then $oexcel = _ExcelBookOpen($dir & "\OfficeList.xls",1, False) else $oexcel = _ExcelBookNew(1) $oexcel_exists = 1 $Excel_Name = _ExcelSheetNameSet($oexcel, "Office Language") _ExcelSheetDelete($oexcel,"Blad2") _ExcelSheetDelete($oexcel,"Blad3") _ExcelWriteCell($oexcel, "Machine Naam:",1,1) _ExcelWriteCell($oexcel, "Login Naam:",1,2) _ExcelWriteCell($oexcel, "Machine Account:",1,3) _excelwritecell($oexcel, "Office taal:",1,4) EndIf _ExcelFontSetProperties($oexcel,1,1,1,5,true,false,false) call("User_credentials") call("Write_credentials") ;functie om gebruikers gegevens te verzamelen. Func User_Credentials() $User_name = @UserName $User_account = @UserProfileDir $Machine_naam = @ComputerName $Machine_Office = "?" if FileExists("C:\Program Files\Microsoft Office\Office12\EXCEL.EXE") Then $msg= RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Common\LanguageResources\","SKULanguage") Else $msg= RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Common\LanguageResources\","SKULanguage") EndIf Select case $msg = 1043 $Machine_Office = "NLD" Case $msg = 1033 $Machine_Office = "ENG" EndSelect EndFunc func Write_credentials() ;schrijf de credentials naar excel en sla excel op _ExcelWriteCell($oexcel,$Machine_naam,$Row,1) _ExcelWriteCell($oexcel, $User_name,$Row,2) _ExcelWriteCell($oexcel, $User_account,$Row,3) _ExcelWriteCell($oexcel,$Machine_Office,$Row,4) $Row = $Row + 1 IniWrite($settings,"Excel","Row",$Row) Select case $oexcel_exists = 1 _ExcelBookSaveAs($oexcel,$dir & "\OfficeList") Case $oexcel_exists = 2 _ExcelBookSave($oexcel) EndSelect _ExcelBookClose($oexcel) EndFunc now when i run it directly from Scite it works perfectly, when i compile it to an .exe and run it from the directory where the exe is created it works fine, but as soon as i move the exe to an 2nd drive partition , the program runs and the _ExcelBookSaveAs() stops working, if i use an exsisting excel file it works so the only part that stops this script is the _ExcelBookSaveAs() the version of Autoit i use is : 3.3.6.1 the comments in this script are in dutch if any questions arise wich need commenting for you guys let me know a badly written code is better than a unwritten onea good written code is even better.but there is always room for improvement. :)
water Posted June 5, 2013 Posted June 5, 2013 What is the value of @error after _ExcelBookSaveAs has failed? 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
BrewManNH Posted June 5, 2013 Posted June 5, 2013 You should check the return value of _ExcelBookSaveAs and see if it tells you anything. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Gianni Posted June 5, 2013 Posted June 5, 2013 try to declare the $dir variable as global Global $dir = @ScriptDir hi Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
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