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

Strange Excel problem

$
0
0

Hi guy's 

it's been a while since i needed some help but this is one strange cookie  :geek:

 

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.

AutoIt         
  1. ; Tool t.b.v. Office pakket installatie
  2. ; controleer welke machine welke taal van Office geinstalleerd heeft.
  3. #include "Excel.au3"
  4. $dir = @ScriptDir
  5. if FileExists($dir & "\Settings.ini") Then
  6. $settings = $dir & "\Settings.ini"
  7. $Row = IniRead($settings,"Excel","Row","2")
  8. $Row = 2
  9. $settings = $dir & "\Settings.ini"
  10. $User_name = 0
  11. $User_account = 0
  12. $Machine_naam = 0
  13. $Machine_Office = 0
  14. $oexcel_exists = 0 ; 1: created new 2: existed
  15. if FileExists($dir & "\OfficeList.xls") then
  16. $oexcel = _ExcelBookOpen($dir & "\OfficeList.xls",1, False)
  17. $oexcel = _ExcelBookNew(1)
  18. $oexcel_exists = 1
  19. $Excel_Name = _ExcelSheetNameSet($oexcel, "Office Language")
  20. _ExcelSheetDelete($oexcel,"Blad2")
  21. _ExcelSheetDelete($oexcel,"Blad3")
  22.  
  23. _ExcelWriteCell($oexcel, "Machine Naam:",1,1)
  24. _ExcelWriteCell($oexcel, "Login Naam:",1,2)
  25. _ExcelWriteCell($oexcel, "Machine Account:",1,3)
  26. _excelwritecell($oexcel, "Office taal:",1,4)
  27. call("User_credentials")
  28.  
  29. call("Write_credentials")
  30. ;functie om gebruikers gegevens te verzamelen.
  31. Func User_Credentials()
  32. $User_name = @UserName
  33. $User_account = @UserProfileDir
  34. $Machine_naam = @ComputerName
  35. $Machine_Office = "?"
  36.  
  37. if FileExists("C:\Program Files\Microsoft Office\Office12\EXCEL.EXE") Then 
  38. $msg= RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Common\LanguageResources\","SKULanguage")
  39. $msg= RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Common\LanguageResources\","SKULanguage") 
  40. case $msg  = 1043
  41. $Machine_Office = "NLD"
  42. Case $msg = 1033
  43. $Machine_Office = "ENG"
  44.  
  45. func Write_credentials()
  46. ;schrijf de credentials naar excel en sla excel op
  47. _ExcelWriteCell($oexcel,$Machine_naam,$Row,1)
  48. _ExcelWriteCell($oexcel, $User_name,$Row,2)
  49. _ExcelWriteCell($oexcel, $User_account,$Row,3)
  50. _ExcelWriteCell($oexcel,$Machine_Office,$Row,4)
  51. $Row = $Row + 1
  52. IniWrite($settings,"Excel","Row",$Row)
  53. case $oexcel_exists = 1
  54.     _ExcelBookSaveAs($oexcel,$dir & "\OfficeList")
  55. Case $oexcel_exists = 2
  56.     _ExcelBookSave($oexcel)

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

 


Viewing all articles
Browse latest Browse all 12506

Trending Articles



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