| View previous topic :: View next topic |
| Author |
Message |
Crusty Guest
|
Posted: Thu Mar 11, 2004 7:51 am Post subject: Mail Merge Execute with Viisual Fox Pro |
|
|
Hello!
Ich have a problem with the Mail Merge Execute. In some posts people describe that they have used a xJob interface to exectue the mail merge and in other posts people executed it like this:
| Code: | Dim args(8)
Set args(0) = OOoPropertyValue("DataSourceName", "txt")
Set args(1) = OOoPropertyValue("DocumentURL", "file:///....")
....
Set objMailMerge = objServiceManager.createInstance("com.sun.star.text.MailMerge")
objMailMerge.Execute args() |
How should I execute mail merge in Visual FoxPro?
What is wrong with the array or the parameter?
Here is my "Code-Snippet":
| Code: |
*// OpenOffice is started and a document was opened...
oDatabaseContext = oSManager.createInstance("com.sun.star.sdb.DatabaseContext")
oDataSource = oSManager.createInstance("com.sun.star.sdb.DataSource")
cDataSourceName = "TestDataSource"
oDatabaseContext.registerObject(cDataSourceName, oDataSource )
oDataSource.setPropertyValue("URL", "sdbc:dbase:file:///c:/temp/")
oConnection = oDataSource.getConnection("","")
LOCAL ARRAY laPropertyValue[2]
laPropertyValue[1] = createStruct( @loReflection,"com.sun.star.beans.NamedValue" )
laPropertyValue[1].NAME = "DocumentURL"
laPropertyValue[1].VALUE = "file:///c:/temp/mailmerge.sxw"
laPropertyValue[2] = createStruct( @loReflection,"com.sun.star.beans.NamedValue" )
laPropertyValue[2].NAME = "DataSourceName"
laPropertyValue[2].VALUE = "TestDataSource"
oMerge = oSManager.createInstance("com.sun.star.text.MailMerge")
COMARRAY(oMerge, 10)
oMerge.Execute( @laPropertyValue )
Return
Function createStruct( toReflection, tcTypeName)
LOCAL loPropertyValue,loTemp
loPropertyValue= createobject( "relation" )
toReflection.forName( tcTypeName).createobject(@loPropertyValue)
return ( loPropertyValue)
ENDFUNC
|
|
|
| Back to top |
|
 |
Crusty General User

Joined: 11 Mar 2004 Posts: 8
|
Posted: Fri Mar 12, 2004 3:53 am Post subject: |
|
|
The Solution should be like this....
| Code: |
LOCAL ARRAY laPropertyValue[7]
lnAIndex = 1
*// this parameter geturns an error!
*!* laPropertyValue[lnAIndex] = oSManager.Bridge_GetStruct( "com.sun.star.beans.NamedValue" )
*!* laPropertyValue[lnAIndex].NAME = "DocumentURL"
*!* laPropertyValue[lnAIndex].VALUE = "file:///C:/temp/result"
*!* lnAIndex = lnAIndex +1
laPropertyValue[lnAIndex] = oSManager.Bridge_GetStruct( "com.sun.star.beans.NamedValue" )
laPropertyValue[lnAIndex].NAME = "DataSourceName"
laPropertyValue[lnAIndex].VALUE = "DataSource"
lnAIndex = lnAIndex +1
laPropertyValue[lnAIndex] = oSManager.Bridge_GetStruct( "com.sun.star.beans.NamedValue" )
laPropertyValue[lnAIndex].NAME = "ActiveConnection"
laPropertyValue[lnAIndex].VALUE = oConnection
lnAIndex = lnAIndex +1
laPropertyValue[lnAIndex] = oSManager.Bridge_GetStruct( "com.sun.star.beans.NamedValue" )
laPropertyValue[lnAIndex].NAME = "CommandType"
laPropertyValue[lnAIndex].VALUE = 2
lnAIndex = lnAIndex +1
laPropertyValue[lnAIndex] = oSManager.Bridge_GetStruct( "com.sun.star.beans.NamedValue" )
laPropertyValue[lnAIndex].NAME = "Command"
laPropertyValue[lnAIndex].VALUE = "select * from kliste"
lnAIndex = lnAIndex +1
laPropertyValue[lnAIndex] = oSManager.Bridge_GetStruct( "com.sun.star.beans.NamedValue" )
laPropertyValue[lnAIndex].NAME = "OutputType"
laPropertyValue[lnAIndex].VALUE = 2
lnAIndex = lnAIndex +1
laPropertyValue[lnAIndex] = oSManager.Bridge_GetStruct( "com.sun.star.beans.NamedValue" )
laPropertyValue[lnAIndex].NAME = "OutputURL"
laPropertyValue[lnAIndex].VALUE = cOutputDir
lnAIndex = lnAIndex +1
laPropertyValue[lnAIndex] = oSManager.Bridge_GetStruct( "com.sun.star.beans.NamedValue" )
laPropertyValue[lnAIndex].NAME = "FileNamePrefix"
laPropertyValue[lnAIndex].VALUE = "result"
lnAIndex = lnAIndex +1
oMerge.Execute( @laPropertyValue )
|
But the result is not like it should be... (the documents will be generated but the merge field content of the datasource is missing....)
Have anyone of you an idea to fix this? |
|
| 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
|