| View previous topic :: View next topic |
| Author |
Message |
Guenole Newbie

Joined: 25 Apr 2003 Posts: 1
|
Posted: Fri Apr 25, 2003 1:28 am Post subject: Visual Foxpro and OpenOffice |
|
|
Hello *
I write a program in Visual Foxpro who open a document, search and replace some characters, store the document, and close Openoffice. Now, i wan't to print it, but it doesn't work :-(
Please, is someone can help me ?
Thank you to everybody
My code (the print doesn't work) :
LOCAL ARRAY laNoArgs[1]
LOCAL oSManager, oSDesktop, oStarDoc, oCursor, oSearch, oResult, oFound, PrintOpts
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.
oStarDoc = oSDesktop.LoadComponentFromUrl("file:///r:/girc6/word6/rel1.sxw", "_blank",0, @laNoargs)
oStarDoc.print()
oStarDoc.dispose()
OsDesktop.terminate()
RELEASE oSManager, oSDesktop
&& messagebox("That's all folks")
Function createStruct(toReflection,tcTypeName )
local loPropertyValue
loPropertyValue = createobject( "relation" )
toReflection.forName(tcTypeName).createobject(@loPropertyValue)
return ( loPropertyValue )
endproc |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Wed May 07, 2003 9:07 am Post subject: Questions about your Visual FoxPro code |
|
|
Sorry I can't help (at least right now) with why you can't print, but I am studying your VFP code and have a few questions.
I can't seem to call LoadComponentFromUrl with only 3 arguments, so I guess that is why you create teh laNoArgs[] array? I assume you have to make that array contain at least 1 element, so you put in a harmless argument (i.e. ReadOnly = .F.).
In your function CreateStruct(), why do you CreateObject( "Relation" ). As far as I can tell, this is VFP's Relation object. I can, for example call the ReadExpression() method of it. Why do you then pass this to the CreateObject method of an interface of type PropertyValue? Is it just because you have to pass *something* in to the CreateObject method of XIdlClass? |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Wed May 28, 2003 12:21 pm Post subject: I can print an OpenOffice.org document from Visual FoxPro |
|
|
I think I have solved your problem.
I can open and print an OOo document from Visual FoxPro.
I've developed a Visual FoxPro library of functions that provide "sugar coated" access to OpenOffice.org from Visual FoxPro.
Please let me know if you're interested, still here, still following this old thread, etc. |
|
| Back to top |
|
 |
fons Newbie

Joined: 06 Feb 2005 Posts: 1
|
Posted: Sun Feb 13, 2005 5:15 am Post subject: backspace from visual foxpro |
|
|
I've managed to create a way of manipulating templates from within Visual foxpro.
I can open a template, search and replace a textstring. it was rather easy.
In a template a use a fieldname <field> search and replace this field with data from my database......not high tech but it does the job.
But I have one problem: occasionaly i want the line removed on which the field <fieldname> occurs
<companyname>
<att>
<street>
it's easy to replace the fields with the text from my database
BUT if field <att> doesn't exist i ALSO want to delete the line (pressing a backspace) would be sufficient.
Has anyone has an idea?
With kind regards
Fons |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Sat Feb 19, 2005 8:21 am Post subject: |
|
|
Your question seems more of a general Writer / Macro question. Perhaps you should post your question as a new thread? I don't think that using VFP is relevant to the problem. The same API calls would be necessary to delete the line in Writer no matter what programming language you were using.
I am not that familiar with Writer, so I don't have an answer for you. _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
hgrollea Newbie

Joined: 22 Feb 2005 Posts: 4
|
Posted: Wed Feb 23, 2005 5:53 am Post subject: Re: Visual Foxpro and OpenOffice |
|
|
[quote="Guenole"]Hello *
I write a program in Visual Foxpro who open a document, search and replace some characters, store the document, and close Openoffice. Now, i wan't to print it, but it doesn't work
From Hervé Groleau - Chambéry - France
So I do all you are doing in VFP and also in VBA (my idea being to do an ocx for VFP and Delphi)
I don't success to implement 'print' function under VFP, but Vba :
<<
Public Sub Print_doc(nbr_ex As Integer)
If nbr_ex > 0 Then
Set vTabParam(0) = SetOOoProp("CopyCount", nbr_ex) '(cName, uValue)
' Other possible params :
' ("FileName","file///...sxw") : un autre (non ouvert )
' ("Collate",True or False)
' ("Pages","1-4;10") ' comme word = pages 1 à 4 et la 10
CallByName objDocument, "print", VbMethod, vTabParam ' ou le currentDoc
End If
End Sub
Rem ------------------------ Fctn SetOOoProp ----------------------------------------
' Crée une structure spéciale OO accessible VBA ! très DELICAT, ne rien modifier !!!!!!
Function SetOOoProp(cName, uValue) As Object
Dim oPropValue As Object
' objServiceManager already created
Set oPropValue = objServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
oPropValue.Name = cName
oPropValue.Value = uValue
Set SetOOoProp = oPropValue
End Function
>>
we have to use CallByName successfully in Vba, because object.print will use vba print and not object print! It also does that in VFP, but we don't get for "callbyname" ...
Do you know to do on VFP :
* insert a page_break at end of document ? I'm doing :
<<Public Sub Doc_End() ' Rem utilise objcursor
objCursor.gotoEnd (False) '
End Sub
objCursor.setPropertyValue "BreakType", 5 ' OK mais au début !
>>
* copy-paste ?
(I can't implement interface xaccessibletext...) -> not registered ?!?
And if you speak french, it's cool!
Thanks |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|