web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

Microsoft Dynamics NAV DotNet objSelection.InsertFile

German NAV Developer Team Profile Picture German NAV Develope... 1,081

 

Mit der Microsoft.Office.Interop.Word Bibliothek stehen Ihnen fast unendlich viele Möglichkeiten offen mit Microsoft Dynamics NAV und Office zu interagieren.

Heute möchte ich Ihnen ein kurzes Beispiel zeigen, wie Sie z.B. eine bestehende Word Datei in ein neues erstelltes Dokument am Ende einfügen können.

Als ein Szenario kann man sich hier vorstellen, dass es sich hier z.B. um die „Allgemeinen Geschäftsbedingungen“ handelt, die Sie zentral speichern wollen, aber nicht jedem Dokument welches Sie aus NAV erstellen beinhaltet von Grund auf angehängt sein soll.

Name DataType Subtype   

objWord    DotNet Microsoft.Office.Interop.Word.ApplicationClass.'Microsoft.Office.Interop.Word, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'   
objDoc DotNet Microsoft.Office.Interop.Word.Document.'Microsoft.Office.Interop.Word, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'   
objSelection    DotNet Microsoft.Office.Interop.Word.Selection.'Microsoft.Office.Interop.Word, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'
WordHelper DotNet Microsoft.Dynamics.Nav.Integration.Office.Word.WordHelper.'Microsoft.Dynamics.Nav.Integration.Office, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
RangeParam    Text  
BoolParam    Boolean  
wdMovement    Integer  
wdUnit    Integer  
wdBreak    Integer  

 

OnRun()
BoolParam := FALSE;
objWord := objWord.ApplicationClass;
objWord.Visible := TRUE;
objDoc := WordHelper.AddDocument(objWord);
objSelection := objWord.Selection;
objSelection.TypeText('Titel');
objSelection.TypeParagraph();
wdUnit := 6;  //6 = wdStory
wdMovement := 0;  //0 = wdMove
objSelection.EndKey(wdUnit, wdMovement);
wdBreak := 2;  //2 = wdSectionBreakNextPage
objSelection.InsertBreak(wdBreak);
objSelection.InsertFile('C:\temp\AGBS.docx', RangeParam, BoolParam, BoolParam, BoolParam);

 

Das Ergebnis sieht dann wie folgt aus:

image

 

These postings are provided "AS IS" with no warranties and confer no rights. You assume all risk for your use.

Mit freundlichen Grüßen

Sebastian Röttel

Microsoft Dynamics Germany

Comments

*This post is locked for comments