Jump to content
Sign in to follow this  

Strange Excel problem

Recommended Posts

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.

; 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")
$Row = 2
$settings = $dir & "\Settings.ini"
$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)
$oexcel = _ExcelBookNew(1)
$oexcel_exists = 1
$Excel_Name = _ExcelSheetNameSet($oexcel, "Office Language")

_ExcelWriteCell($oexcel, "Machine Naam:",1,1)
_ExcelWriteCell($oexcel, "Login Naam:",1,2)
_ExcelWriteCell($oexcel, "Machine Account:",1,3)
_excelwritecell($oexcel, "Office taal:",1,4)

;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")
$msg= RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Common\LanguageResources\","SKULanguage")  
case $msg  = 1043
$Machine_Office = "NLD" 
Case $msg = 1033
$Machine_Office = "ENG" 

func Write_credentials()
;schrijf de credentials naar excel en sla excel op
_ExcelWriteCell($oexcel, $User_name,$Row,2)
_ExcelWriteCell($oexcel, $User_account,$Row,3)
$Row = $Row + 1
case $oexcel_exists = 1
    _ExcelBookSaveAs($oexcel,$dir & "\OfficeList")
Case $oexcel_exists = 2 

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 :

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. :)

Share this post

Link to post
Share on other sites

What is the value of @error after _ExcelBookSaveAs has failed?

My UDFs and Tutorials:


Active Directory (NEW 2020-10-10 - Version - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version - Download
Outlook Tools (2019-07-22 - Version - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version - Download - General Help & Support - Wiki

ADO - Wiki, WebDriver - Wiki


Share this post

Link to post
Share on other sites

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 Gude
How 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

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...