K Feening
asked on
Mail Merge
I have an existing Word Document and want to merge line to specific positions in the letter
There is a Logo on the right side and below that on the left I need a Date Then Name Address then after the Section Probation Letter I need to add Dear XXXXX I dont want to insert lines, is there a way to add the information to a position in the Document without moving the existing letter down with inserts
Document -
Date:
[Given Name] [Surname]
[Address Line 1]
[Suburb] [State] [Postcode]
Probation Letter (Existing in Document)
Dear [Given Name],
Congratulations on the successful completion of your probation period
There is a Logo on the right side and below that on the left I need a Date Then Name Address then after the Section Probation Letter I need to add Dear XXXXX I dont want to insert lines, is there a way to add the information to a position in the Document without moving the existing letter down with inserts
Document -
Date:
[Given Name] [Surname]
[Address Line 1]
[Suburb] [State] [Postcode]
Probation Letter (Existing in Document)
Dear [Given Name],
Congratulations on the successful completion of your probation period
ASKER
sorry This is done in Delphi using
// Create an instance of Word and make it visible
wrdApp := CreateOleObject('Word.Appl ication');
wrdApp.Visible := True;
// Create a new document
wrdDoc := wrdApp.Documents.Add(fname );
wrdDoc.Select;
wrdSelection := wrdApp.Selection;
wrdMailMerge := wrdDoc.MailMerge;
// Create MailMerge data file
CreateMailMergeDataFile;
// Insert Merge Data
wrdSelection.ParagraphForm at.Alignme nt := wdAlignParagraphLeft;
wrdMergeFields := wrdMailMerge.Fields;
InsertLines(10);
wrdMergeFields.Add(wrdSele ction.Rang e,'FirstNa me');
wrdSelection.TypeText(' ');
wrdMergeFields.Add(wrdSele ction.Rang e,'LastNam e');
wrdSelection.TypeParagraph ;
wrdMergeFields.Add(wrdSele ction.Rang e,'Address ');
wrdSelection.TypeParagraph ;
wrdMergeFields.Add(wrdSele ction.Rang e,'City');
InsertLines(2);
wrdSelection.ParagraphForm at.Alignme nt := wdAlignParagraphJustify;
wrdSelection.TypeText('Dea r ');
wrdMergeFields.Add(wrdSele ction.Rang e,'FirstNa me');
wrdSelection.TypeText(' ');
InsertLines(1);
// Create an instance of Word and make it visible
wrdApp := CreateOleObject('Word.Appl
wrdApp.Visible := True;
// Create a new document
wrdDoc := wrdApp.Documents.Add(fname
wrdDoc.Select;
wrdSelection := wrdApp.Selection;
wrdMailMerge := wrdDoc.MailMerge;
// Create MailMerge data file
CreateMailMergeDataFile;
// Insert Merge Data
wrdSelection.ParagraphForm
wrdMergeFields := wrdMailMerge.Fields;
InsertLines(10);
wrdMergeFields.Add(wrdSele
wrdSelection.TypeText(' ');
wrdMergeFields.Add(wrdSele
wrdSelection.TypeParagraph
wrdMergeFields.Add(wrdSele
wrdSelection.TypeParagraph
wrdMergeFields.Add(wrdSele
InsertLines(2);
wrdSelection.ParagraphForm
wrdSelection.TypeText('Dea
wrdMergeFields.Add(wrdSele
wrdSelection.TypeText(' ');
InsertLines(1);
Just a suggestion.
Use some reporting tools to create resulting form. Save it as .pdf format. IMHO more preferable way in email then MS Word document.
Use some reporting tools to create resulting form. Save it as .pdf format. IMHO more preferable way in email then MS Word document.
ASKER
Sorry I don't understand it's not an email and they don't want a pdf file its a Form letter to selected staff from a Interbase Database I insert the name Address from then database into the existing MS Word document and then they print and post to the staff. I need to know if you can insert the name address and Dear XXXXXX in specific spots in the MS Word Document without the existing information moving from its origional saved Word Document position.
Thanks
Thanks
So, place variables in existing MS Word document, then assign data to that variables in your application.
ASKER
How do you add variables using MS Word and how to you assign data to them or find them using Delphi
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks tried the example but it has problems is it the same code for Delphi
The wizard allows you to check formatting and correct before completing the merge and printing.
... Thinkpads_User