navision automation in ms-word

vijaydidmca2003
Member Posts: 27
can any body give me any code, so that i could throw (generate)
navision report in ms-word.
can any body show me how i can use coding for "ms office-word automation" in navision.
i have allready used following coding, but it is showing error.
Name DataType Subtype Length
wrdApp Automation 'Microsoft Word 11.0 Object Library'.Application
wrdDoc Automation 'Microsoft Word 11.0 Object Library'.Document
wrdRange Automation 'Microsoft Word 11.0 Object Library'.Range
Companyinfo.FIND;
userinfo.GET(USERID);
CREATE(wrdApp);
TemplateName:='c:\template.doc';
wrdDoc:=wrdApp.Documents.Add(TemplateName);
wrdApp.ActiveDocument.Fields.Update;
wrdRange:=wrdApp.ActiveDocument.Fields.Item(1).Result;
wrdRange.Text:=USERID;
wrdRange.Bold:=1;
wrdApp.Visible:=TRUE;
wrdApp.ActiveDocument.Fields.Unlink;
when i used above coding i found following error:
"The call to member item failed.the requested member of the collection does not exist."
and the debugger stops at the below given line.Pls give me any solution.thanks.
wrdRange:=wrdApp.ActiveDocument.Fields.Item(1).Result;
regards
vijay tiwari.
navision report in ms-word.
can any body show me how i can use coding for "ms office-word automation" in navision.
i have allready used following coding, but it is showing error.
Name DataType Subtype Length
wrdApp Automation 'Microsoft Word 11.0 Object Library'.Application
wrdDoc Automation 'Microsoft Word 11.0 Object Library'.Document
wrdRange Automation 'Microsoft Word 11.0 Object Library'.Range
Companyinfo.FIND;
userinfo.GET(USERID);
CREATE(wrdApp);
TemplateName:='c:\template.doc';
wrdDoc:=wrdApp.Documents.Add(TemplateName);
wrdApp.ActiveDocument.Fields.Update;
wrdRange:=wrdApp.ActiveDocument.Fields.Item(1).Result;
wrdRange.Text:=USERID;
wrdRange.Bold:=1;
wrdApp.Visible:=TRUE;
wrdApp.ActiveDocument.Fields.Unlink;
when i used above coding i found following error:
"The call to member item failed.the requested member of the collection does not exist."
and the debugger stops at the below given line.Pls give me any solution.thanks.
wrdRange:=wrdApp.ActiveDocument.Fields.Item(1).Result;
regards
vijay tiwari.
0
Comments
-
There's a great example in the Application Designers Guide....
Here's a sample of how to export nav VENDOR data into word.
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 250CREATE(wdApp); TemplateName:='c:\"YourWordTemplateNameHere".dot'; wdDoc := wdApp.Documents.Add(TemplateName); wdApp.ActiveDocument.Fields.Update; wdRange :=wdApp.ActiveDocument.Fields.Item(1).Result; wdRange.Text := FORMAT(WORKDATE,0,'<year4>'); wdRange.Bold :=1; wdRange :=wdApp.ActiveDocument.Fields.Item(2).Result; wdRange.Text := "No."; wdRange.Bold :=0; wdRange :=wdApp.ActiveDocument.Fields.Item(3).Result; wdRange.Text := Name; wdRange.Bold :=0; wdRange :=wdApp.ActiveDocument.Fields.Item(4).Result; wdRange.Text := Address; wdRange.Bold :=0; wdRange :=wdApp.ActiveDocument.Fields.Item(5).Result; wdRange.Text := "Address 2"; wdRange.Bold :=0; wdRange :=wdApp.ActiveDocument.Fields.Item(6).Result; wdRange.Text := City; wdRange.Bold :=0; wdRange :=wdApp.ActiveDocument.Fields.Item(7).Result; wdRange.Text := State; wdRange.Bold :=0; wdRange :=wdApp.ActiveDocument.Fields.Item(8).Result; wdRange.Text := "ZIP Code"; wdRange.Bold :=0; wdRange :=wdApp.ActiveDocument.Fields.Item(9).Result; wdRange.Text := "Contact Name"; wdRange.Bold :=0; wdRange :=wdApp.ActiveDocument.Fields.Item(10).Result; wdRange.Text := "Vendor Phone No."; wdRange.Bold :=0; wdApp.Visible :=TRUE; wdApp.ActiveDocument.Fields.Unlink; CLEAR(wdApp);
0 -
Also if you hve not read the step by step example here's the snipit.
http://savatage99.googlepages.com/WordA ... romADG.pdf0 -
I have followed these instructions and the doc but I keep getting an error relating to the creation of the file. I even deleted the code and started over thinking that the automation variables were corrupt.
I get "word was unable to create this document. It may be corrupt.
Try one or more of the following:
* open and repair the file.
* open the file with the text recovery converter.
I have tried all this has anyone else experienced this problem and been able to get around it?
Any help would be appreciated since I am still at home plate on this!
It is obvious that it is not finding the file but I dont know why? All looks correct I have tried both local and network directories.
I FINALLY GOT IT TO WORK BY RENAMING THE FILE TO FILNAME.DOC not .DOT I dont know why the .DOT (Document template did not work)!0 -
Let's take step back...
Ok first you followed the ADG steps - correct?
Does You Automation variable look like what I posted Below?
Does your PC have Word Installed?
Did you save your Word Doc as a Template .DOT not .DOC?
How did the Template creation go for you?To create the template:
1 Open Word and open a new document.
2 Click Insert, Field and add a field from the Mail Merge category called MergeField.
3 Enter Contact as the field name.
The simple template that you are going to use in this example should contain the
following fields: See Link to ADG
4 Create these six fields and save the Word document as Discount.dot0 -
Glad you got it to work.. was the problem this line?
TemplateName:='c:\"YourWordTemplateNameHere".dot';
perhaps your code calls for DOC0 -
Hi,
I'm using MS Word and it works perfectly but now I want to save the word document result as 'c:\MyDoc.docx'
Is there a save function that I can use????
Thanks for your Help.Regards
Hanen TALBI0 -
Savatage wrote:Also if you hve not read the step by step example here's the snipit.
http://savatage99.googlepages.com/WordA ... romADG.pdf
Hi.
I have almost that situation described in quoted link. But I need to print a letters for set of Customers in one Word document. In another words - for each Customer record I have one page in Word document, so if I would like to print 5 records from Customer table, I get 5 pages in Word.
I need help in modification of this code for creating one Word document for set of records:Savatage wrote:There's a great example in the Application Designers Guide....
Here's a sample of how to export nav VENDOR data into word.
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 250CREATE(wdApp); TemplateName:='c:\"YourWordTemplateNameHere".dot'; wdDoc := wdApp.Documents.Add(TemplateName); wdApp.ActiveDocument.Fields.Update; wdRange :=wdApp.ActiveDocument.Fields.Item(1).Result; wdRange.Text := FORMAT(WORKDATE,0,'<year4>'); wdRange.Bold :=1; wdRange :=wdApp.ActiveDocument.Fields.Item(2).Result; wdRange.Text := "No."; wdRange.Bold :=0; wdRange :=wdApp.ActiveDocument.Fields.Item(3).Result; wdRange.Text := Name; wdRange.Bold :=0; wdRange :=wdApp.ActiveDocument.Fields.Item(4).Result; wdRange.Text := Address; wdRange.Bold :=0; wdRange :=wdApp.ActiveDocument.Fields.Item(5).Result; wdRange.Text := "Address 2"; wdRange.Bold :=0; wdRange :=wdApp.ActiveDocument.Fields.Item(6).Result; wdRange.Text := City; wdRange.Bold :=0; wdRange :=wdApp.ActiveDocument.Fields.Item(7).Result; wdRange.Text := State; wdRange.Bold :=0; wdRange :=wdApp.ActiveDocument.Fields.Item(8).Result; wdRange.Text := "ZIP Code"; wdRange.Bold :=0; wdRange :=wdApp.ActiveDocument.Fields.Item(9).Result; wdRange.Text := "Contact Name"; wdRange.Bold :=0; wdRange :=wdApp.ActiveDocument.Fields.Item(10).Result; wdRange.Text := "Vendor Phone No."; wdRange.Bold :=0; wdApp.Visible :=TRUE; wdApp.ActiveDocument.Fields.Unlink; CLEAR(wdApp);
Thanks in advance!0 -
Freeman wrote:Savatage wrote:Also if you hve not read the step by step example here's the snipit.
http://savatage99.googlepages.com/WordA ... romADG.pdf
Hi.
I have almost that situation described in quoted link. But I need to print a letters for set of Customers in one Word document. In another words - for each Customer record I have one page in Word document, so if I would like to print 5 records from Customer table, I get 5 pages in Word.
I've solved my problem by myself ](*,) ](*,) ](*,)
If someone interested, here is modified code:// Code added Vendor.reset; Vendor.setrange("No.", '1', '5'); if Vendor.FINDSET THEN BEGIN // -- CREATE(wdApp); TemplateName:='c:\"YourWordTemplateNameHere".dot'; wdDoc := wdApp.Documents.Add(TemplateName); wdApp.ActiveDocument.Fields.Update; // Code added wdApp.Selection.WholeStory; // Select and copy templates lines wdApp.Selection.Copy; REPEAT // -- wdRange :=wdApp.ActiveDocument.Fields.Item(1).Result; wdRange.Text := FORMAT(WORKDATE,0,'<year4>'); wdRange.Bold :=1; wdRange :=wdApp.ActiveDocument.Fields.Item(2).Result; wdRange.Text := "No."; wdRange.Bold :=0; wdRange :=wdApp.ActiveDocument.Fields.Item(3).Result; wdRange.Text := Name; wdRange.Bold :=0; wdRange :=wdApp.ActiveDocument.Fields.Item(4).Result; wdRange.Text := Address; wdRange.Bold :=0; wdRange :=wdApp.ActiveDocument.Fields.Item(5).Result; wdRange.Text := "Address 2"; wdRange.Bold :=0; wdRange :=wdApp.ActiveDocument.Fields.Item(6).Result; wdRange.Text := City; wdRange.Bold :=0; wdRange :=wdApp.ActiveDocument.Fields.Item(7).Result; wdRange.Text := State; wdRange.Bold :=0; wdRange :=wdApp.ActiveDocument.Fields.Item(8).Result; wdRange.Text := "ZIP Code"; wdRange.Bold :=0; wdRange :=wdApp.ActiveDocument.Fields.Item(9).Result; wdRange.Text := "Contact Name"; wdRange.Bold :=0; wdRange :=wdApp.ActiveDocument.Fields.Item(10).Result; wdRange.Text := "Vendor Phone No."; wdRange.Bold :=0; // Code added wdApp.ActiveDocument.Fields.Unlink; // Replace all the fields in the first letter wdApp.Selection.EndKey; // Go to end of the document wdApp.Selection.InsertBreak; // Start new page wdApp.Selection.PasteAndFormat(16); // Paste copied template UNTIL Vendor.NEXT = 0; // -- wdApp.Visible :=TRUE; // Commented wdApp.ActiveDocument.Fields.Unlink; CLEAR(wdApp); END; // Code added
0 -
If I want to the same thing but using Excel and each sheet with the vendor code, how can I do it???
please help, I have to deal with that today or I'll have a serious problem with the customer((((((((((((((((((((((((((((((
Regards
Hanen TALBI0
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