Write in Word document using automation

Serval
Member Posts: 51
Hi people !
I'm using Word automations. I have to write some informations from Navision to a Word template wich is stored as a blob in the Interaction Template table. There are already some fields created in the Word template wich is structured as header and a footer.
How can I perform the following actions :
1. write a value from Navision to a field in the Word Document.
2. write additional texts between the header and the footer. This means that I have to know where the header ends and where the bottom starts in order to prevent replacing my existing fields.
What are the properties and/or methods to use ?
Any samples in VB are welcome.
NB : I have already search the forum. I found some topics those have already help me to perfom a lot of others actions, but I still need to know how to do for the 2 above and time is money ...
Thx in advance.
I'm using Word automations. I have to write some informations from Navision to a Word template wich is stored as a blob in the Interaction Template table. There are already some fields created in the Word template wich is structured as header and a footer.
How can I perform the following actions :
1. write a value from Navision to a field in the Word Document.
2. write additional texts between the header and the footer. This means that I have to know where the header ends and where the bottom starts in order to prevent replacing my existing fields.
What are the properties and/or methods to use ?
Any samples in VB are welcome.
NB : I have already search the forum. I found some topics those have already help me to perfom a lot of others actions, but I still need to know how to do for the 2 above and time is money ...
Thx in advance.
0
Comments
-
In Microsoft Word
Tools -> Macros -> Record a new Macro.
Manually make all changes you want to do.
Stop Recording.
Check Macro Source Code. You will there the code in VBA that you convert to C/AL.0 -
Thanks nunomaia, the Macro recording function is really helpful.
But I still face the first problem. How to write into a MergeField in a Word document from Navision using automation... ??
](*,)
Thanks.0 -
Have you checked ExecuteMerge function in WordManagement codeunit?Ufuk Asci
Pargesoft0 -
ufuk wrote:Have you checked ExecuteMerge function in WordManagement codeunit?
Is the 'Navision Attain ApplicationHandler'.MergeHandler' automation specific to the Service module and functionalities....? :-k
Anyway, I found another solution, this may not be the perfect solution, but it works :
-I declare a new automation variable (autWrdAp) of Subtype 'Microsoft Word 11.0 Object Library'.Document.
-To find a text and replace it by another text in a word template, I use the Execute method :
autWrdDoc.Content.Find.Execute(FindText,[some others parameters],ReplaceText)0 -
I was wondering what are the other parameters required for autWrdDoc.Content.Find.Execute(FindText,[some others parameters],ReplaceText)
[/quote]0 -
I had some problems regarding replace, but I managed to overcome them by doing:
pWordAF.ActiveWindow.Selection.SetRange(0,0);//select nothing IF pWordAF.ActiveWindow.Selection.Find.Execute(temptext) THEN//find and select pWordAF.ActiveWindow.Selection.TypeText:=pReplaceText;//the actual replace
0 -
Thanks Arhontis, that has solved my problem0
-
Datapac wrote:I was wondering what are the other parameters required for autWrdDoc.Content.Find.Execute(FindText,[some others parameters],ReplaceText)
If those parameters do not need to be changed, just declare two variables :
bParam : boolean
iParam : integer
then run the function as follow :
autWrdDoc.Content.Find.Execute(FindText,,bParam,bParam,bParam,bParam,bParam,bParam,iParam,bParam,ReplaceText);
For more informations about these others parameters, use the Record Macro functionality in Microsoft Word as explain by Nunomaia above.0 -
So I never made an Report form Navision in to Word. Can somebody send me an complete Report so I can see the automations witch are needed to write in an Word Template.0
-
I created a lot of exports to msWord and learned it by using the search button in this forum. Here is a link i started with http://www.mibuso.com/forum/viewtopic.p ... automation0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions