Word Automation
Xav
Member Posts: 25
Hello,
I want use the word automation for the first time. The goal is to pass parameters in a few fields in a word document.
I use Dynamics Nav 5.0 SP1 with XP SP3 and Office 2007.
I try to create a test with this code in a new form :
CompanyInfo.FIND;
CREATE(wdApp);
TemplateName := 'C:\test.dot';
wdDoc := wdApp.Documents.Add(TemplateName);
wdApp.ActiveDocument.Fields.Update;
wdRange := wdAPP.ActiveDocument.Fields.Item(1).Result;
wdRange.Text := CompanyInfo.Name;
wdRange.Bold := 1;
wdRange := wdAPP.ActiveDocument.Fields.Item(2).Result;
wdRange.Text := USERID;
wdRange.Bold := 1;
wdApp.Visible := TRUE;
wdApp.ActiveDocument.Fields.Unlink;
My problem is that the property wdApp.Documents does not exist and therefore I can not compile this code.
Is this code good ?
can you give me some ideas please ?
I want use the word automation for the first time. The goal is to pass parameters in a few fields in a word document.
I use Dynamics Nav 5.0 SP1 with XP SP3 and Office 2007.
I try to create a test with this code in a new form :
CompanyInfo.FIND;
CREATE(wdApp);
TemplateName := 'C:\test.dot';
wdDoc := wdApp.Documents.Add(TemplateName);
wdApp.ActiveDocument.Fields.Update;
wdRange := wdAPP.ActiveDocument.Fields.Item(1).Result;
wdRange.Text := CompanyInfo.Name;
wdRange.Bold := 1;
wdRange := wdAPP.ActiveDocument.Fields.Item(2).Result;
wdRange.Text := USERID;
wdRange.Bold := 1;
wdApp.Visible := TRUE;
wdApp.ActiveDocument.Fields.Unlink;
My problem is that the property wdApp.Documents does not exist and therefore I can not compile this code.
Is this code good ?
can you give me some ideas please ?
0
Comments
-
check this post - follow the instructions
viewtopic.php?f=23&t=33734
the key is getting the globals set up correctly
Name DataType Subtype Length
wdApp Automation 'Microsoft Word 11.0 Object Library'.Application
wdDoc Automation 'Microsoft Word 11.0 Object Library'.Document
wdRange Automation 'Microsoft Word 11.0 Object Library'.Range
TemplateName Text 250
good luck0 -
Thank you for your response.
I got it to work. My problem now is to show the variables in Word.0 -
0
-
Yes, i read it. Thank you. I managed to create the code to open my template word file. But I can not insert field as indicated in the document. I am not a super user word and I do not know what to do with Word 2007.0
-
Other than reviewing the topic "Creating the Template in Word" there's not much more I can say.
If you can't find where Insert->field is use the word help.0 -
I'm trying to follow that example too, but am stumped at the first part - Insert Merge Field. In Office 2007 that command is greyed out and it looks like I have to specify a datasource first ...0
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
- 322 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
