I am trying to do a Mail Merge type operation.
I have a table - Contacts - with 6 fields.
I have created a template in MSWord for 12 labels on a page.
I create contactlabels.doc based on template.
I have fields for each line of the table.
All other aspects of my code are working ok and I see the template on screen as I step through.
I am using the following ( borrowed from foxite ) code to try and populate the fields.
as I step through I see the '<<' - chr (171)- being placed in lcFoundText.
I would then expect to pick up the whole word within the << - >> field markers as lcCommand.
This code does not do that.
Can anyone help with a 'snippet' that will work correctly?
Many thanks
Eric
I have a table - Contacts - with 6 fields.
I have created a template in MSWord for 12 labels on a page.
I create contactlabels.doc based on template.
I have fields for each line of the table.
All other aspects of my code are working ok and I see the template on screen as I step through.
I am using the following ( borrowed from foxite ) code to try and populate the fields.
Code:
PROCEDURE create
* THIS is the code handling the template and creating
* the document.
LOCAL loApp, loDoc
loApp=THIS.WordApplication
loDoc=THIS.WordDocument
loDoc.SaveAs(THIS.ReportFile)
local lcFoundText, lcCommand
loApp.Selection.Find.Execute('\<*\>',,,.T.,,,.T.,1)
lcFoundText=loApp.Selection.Text
DO WHILE SUBSTR(lcFoundText,1,1)='<' AND ;
SUBSTR(lcFoundText,LEN(lcFoundText),1)='>'
lcCommand=loApp.Selection.Text
lcCommand=SUBSTR(lcCommand,1,LEN(lcCommand)-1)
lcCommand=SUBSTR(lcCommand,2)
loApp.Selection.Text=EVALUATE(lcCommand)
loApp.Selection.Find.Execute('\<*\>',,,.T.,,,.T.,1)
lcFoundText=loApp.Selection.Text
ENDDO
loDoc.Save()
ENDPROC
as I step through I see the '<<' - chr (171)- being placed in lcFoundText.
I would then expect to pick up the whole word within the << - >> field markers as lcCommand.
This code does not do that.
Can anyone help with a 'snippet' that will work correctly?
Many thanks
Eric