Jump to content
Sign in to follow this  

[OpenOffice] Template openning

Recommended Posts



I try to write a code with the basics to manipulate the Open Office Calc files (See attachments)

I have the following issue :

I want the template file openned to be hidden. So, I use the boolean TRUE with the parameter HIDDEN but it doesn't work : the template file is always displayed before being closed.

Can anyone try to explain me why can't I manage to work on this calc file in hidden mode ?

Thanks !

(ps : if you wanna use my auto-it code, change the path values $TemplateFilePath and $strFileOut)

#include <Array.au3>

;nom du modèle de tableau

$TemplateFilePath = "C:\Documents and Settings\GLEIZES\Mes documents\Auto It - VBS\Test_OOo.ods" ; modèle

$strFileOut = "C:\Documents and Settings\GLEIZES\Mes documents\Auto It - VBS\Test_OOo_rempli.ods" ; fichier de sauvegarde

;on crée l'objet aidant à la manipulation des documents OOo

$objServiceManager = ObjCreate("com.sun.star.ServiceManager")

$Stardesktop = $objServiceManager.createInstance("com.sun.star.frame.Desktop")

;Paramètre d'ouverture

Local $OpenParam = _ArrayCreate(MakePropertyValue("Hidden", True)) ;FALSE : affichage à l'écran, TRUE : en caché MARCHE PAS !

;Conversion des adresses des fichier modèle & sauvegarde en adresse URL

$TemplateFilePathURL = Convert2URL($TemplateFilePath)

$strFileOutURL =Convert2URL($strFileOut)

;ouverture du modèle

$TemplateFile = $Stardesktop.loadComponentFromURL($TemplateFilePathURL, "_blank", 0, $OpenParam)

;Sélection de la feuille à écrire

$oSheet = $TemplateFile.getSheets().getByIndex(0) ; selection par position

;$oSheet = $TemplateFile.getSheets().getByName("aaa") ; selection par nom

;Ecriture dans la feuille

$oSheet.getCellRangeByName("B4").setFormula("test d'écriture")

;Lire des cellules

$cell = $oSheet.getCellRangeByName("A1").formula



$oSave = _ArrayCreate(MakePropertyValue("FilterName", -1))




Func MakePropertyValue ($cName, $uValue)

Local $Pstruc

$Pstruc = $objServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")

$Pstruc.Name = $cName

$Pstruc.Value = $uValue ; ($uValue)

; MsgBox(0,"", $Pstruc.Value)

Return $Pstruc


Func Convert2URL($fname)

$fname = StringReplace($fname, ":", "|")

$fname = StringReplace($fname, " ", "%20")

$fname = "file:///" & StringReplace($fname, "\", "/")

Return $fname



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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.