Problems with word bookmarks and report
eyjayioc
Member Posts: 3
Hi @ all,
i am looking for a solution to fill bookmarks in a word template (without the word managemnet codeunit) in a report.
Can anyone please add a c/al exlample to open the template (*.dot, *.dotx or *.dotm) and fill a bookmark with text?
thanks a lot (i try it for more than 4 hours :oops: )
i am looking for a solution to fill bookmarks in a word template (without the word managemnet codeunit) in a report.
Can anyone please add a c/al exlample to open the template (*.dot, *.dotx or *.dotm) and fill a bookmark with text?
thanks a lot (i try it for more than 4 hours :oops: )
greetz
eyjay
0
Comments
-
To get you started
IF NOT ISCLEAR(WinWord) THEN CLEAR(WinWord); IF NOT CREATE(WinWord) THEN EXIT; WordDocument := WinWord.Documents.Open(pFile); BMTeller := WordDocument.Bookmarks.Count; WordBookmarks := WordDocument.Bookmarks; WHILE (i < BMTeller) DO BEGIN i += 1; iVar := i; WordBookmark := WordBookmarks.Item(iVar) ; BMMatrix[i] := WordBookmark.Name; END; FOR BMTeller :=1 TO BMTeller DO BEGIN CASE UPPERCASE(BMMatrix[BMTeller]) OF 'BMNAAM': BMFUNC_Naam; END; END; WordDocument.SaveAs(pFile); WordDocument.ActiveWindow.WindowState := 1; // 1 = wdWindowStateMaximize WordDocument.Saved :=TRUE; WinWord.Visible(TRUE); BMFUNC_Naam() GoToBookmark('BMNAAM'); InsertText(SalesHeader."Bill-to Name" + ' ' + SalesHeader."Bill-to Name 2"); GoToBookmark(bookmarkname : Text[30]) wdGoToBookmark := -1; V1 := 0; v2 := 0; WinWord.Selection.GoTo(wdGoToBookmark,V1,v2,bookmarkname); InsertText(Text : Text[1024]) WinWord.Selection.TypeText(Text);0 -
ErictP wrote:To get you started
IF NOT ISCLEAR(WinWord) THEN CLEAR(WinWord); IF NOT CREATE(WinWord) THEN EXIT; WordDocument := WinWord.Documents.Open(pFile); BMTeller := WordDocument.Bookmarks.Count; WordBookmarks := WordDocument.Bookmarks; WHILE (i < BMTeller) DO BEGIN i += 1; iVar := i; WordBookmark := WordBookmarks.Item(iVar) ; BMMatrix[i] := WordBookmark.Name; END; FOR BMTeller :=1 TO BMTeller DO BEGIN CASE UPPERCASE(BMMatrix[BMTeller]) OF 'BMNAAM': BMFUNC_Naam; END; END; WordDocument.SaveAs(pFile); WordDocument.ActiveWindow.WindowState := 1; // 1 = wdWindowStateMaximize WordDocument.Saved :=TRUE; WinWord.Visible(TRUE); BMFUNC_Naam() GoToBookmark('BMNAAM'); InsertText(SalesHeader."Bill-to Name" + ' ' + SalesHeader."Bill-to Name 2"); GoToBookmark(bookmarkname : Text[30]) wdGoToBookmark := -1; V1 := 0; v2 := 0; WinWord.Selection.GoTo(wdGoToBookmark,V1,v2,bookmarkname); InsertText(Text : Text[1024]) WinWord.Selection.TypeText(Text);
hi,
thanks for that answer, but could you please show an overview of the variables? I wrote the code and the system show's an error Unknown variable item: "WordBookmarks.Item(iVar)"
thanks a lot
greetz
eyjay0 -
VAR WinWord@1000000006 : Automation "{00020905-0000-0000-C000-000000000046} 8.3:{000209FF-0000-0000-C000-000000000046}:'Microsoft Word 11.0 Object Library'.Application"; WordDocument@1000000005 : Automation "{00020905-0000-0000-C000-000000000046} 8.3:{00020906-0000-0000-C000-000000000046}:'Microsoft Word 11.0 Object Library'.Document"; WordBookmarks@1000000003 : Automation "{00020905-0000-0000-C000-000000000046} 8.3:{00020967-0000-0000-C000-000000000046}:'Microsoft Word 11.0 Object Library'.Bookmarks"; WordBookmark@1000000002 : Automation "{00020905-0000-0000-C000-000000000046} 8.3:{00020968-0000-0000-C000-000000000046}:'Microsoft Word 11.0 Object Library'.Bookmark"; WordSelection@1000000001 : Automation "{00020905-0000-0000-C000-000000000046} 8.3:{00020975-0000-0000-C000-000000000046}:'Microsoft Word 11.0 Object Library'.Selection"; BMTeller@1000000007 : Integer; BMMatrix@1000000000 : ARRAY [100] OF Text[30]; i@1000000008 : Integer; iVar@1000000009 : Variant;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