Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
OpenOffice Automation
Message
De
18/01/2005 08:38:15
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
00977980
Message ID:
00978048
Vues:
45
>Is there somewhere to read how to Automate OpenOffice with VFP?
>TIA

The following samples were recently posted by Sönke Freitag on the dfpug forum.
LOCAL ARRAY laNoArgs[1] 
 LOCAL oSManager, oSDesktop, oStarDoc, oCursor, oSearch, oResult, oFound 
 
 oSManager = CREATEOBJECT("Com.Sun.Star.ServiceManager.1") 
 oSDesktop = oSManager.createInstance("com.sun.star.frame.Desktop") 
 
 COMARRAY(oSDesktop, 10) 
 loReflection = oSManager.createInstance("com.sun.star.reflection.CoreReflection" ) 
 COMARRAY(loReflection, 10 ) 
 loPropertyValue = createStruct( @loReflection,"com.sun.star.beans.PropertyValue" ) 
 laNoArgs[1] = loPropertyValue 
 laNoArgs[1].NAME = "ReadOnly" 
 laNoArgs[1].VALUE = .F. 
 
 && 
________________________________________
New Document 
 oStarDoc = oSDesktop.loadComponentFromURL( "private:factory/swriter", "_blank", 0, @laNoArgs ) 
 
 && 
________________________________________
Load existing one 
 && oStarDoc = oSDesktop.LoadComponentFromUrl("file:///c:/test.sxw", "_blank",0, @laNoargs) 
 
 && 
________________________________________
Insert some Text 
 oText = oStarDoc.TEXT 
 oTextCursor = oText.CreateTextCursor 
 oTextCursor.gotoEnd(.F.) 
 oText.insertString( oTextCursor, "Hello"+CHR(13)+"World...", .F. ) 
 
 && 
________________________________________
Close 
 && oStarDoc.dispose() 
 && OsDesktop.terminate() 
 && RELEASE oSManager, oSDesktop 
 
 FUNCTION createStruct(toReflection,tcTypeName ) 
 LOCAL loPropertyValue 
 loPropertyValue = CREATEOBJECT( "relation" ) 
 toReflection.forName(tcTypeName).CREATEOBJECT(@loPropertyValue) 
 RETURN ( loPropertyValue ) 
 ENDFUNC
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform