Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Just an idea:</p> <p>At first you will need to download the WordAPI, which can be downloaded right <a href="http://www.must.de/WordAPI.exe" rel="nofollow">here</a>. To create word documents with JAVA, there's a class doing everything you need. The class is called <a href="http://www.must.de/WordProcessing.java" rel="nofollow">WordProcessing</a>.</p> <p>Here's a short preview of the methods implemented in that class:</p> <ul> <li>createNewDocumentFromTemplate(String templateName)</li> <li>createNewDocumentFromTemplateToSelectByUser()</li> <li>setNoteNotMatchingBookmarks(boolean noteNotMatchingBookmarks)</li> <li>typeTextAtBookmark(String bookmark, String textToType)</li> <li>typeTextAtBookmark(String bookmark, String[] linesToType)</li> <li>changeDocumentDirectory(String documentDirectory)</li> <li>saveDocumentAs(String documentName)</li> <li>saveDocumentAsAndClose(String documentName)</li> <li>closeDocument()</li> <li>printAndForget()</li> <li>printToPrinterToSelectByUserAndForget()</li> <li>printAndForget(String printerName)</li> <li>executeMacro(String macroName) &lt;---- Interesting for you</li> <li>quitApplication()</li> <li>exec()</li> </ul> <p>As you can see there are a lot of helpful functions to create your document. </p> <p>Now you can insert an image by calling the executeMacro function.</p> <p>The Macro could look like this:</p> <pre><code>Option Explicit Sub InsertPicture() Dim sPath As String Dim sBildPfad As String Dim lRes As Long 'The path of your picture sBildPfad = "C:\temp" 'remember the current path of the picture sPath = Options.DefaultFilePath(Path:=wdPicturesPath) 'changing the path Options.DefaultFilePath(Path:=wdPicturesPath) = sBildPfad 'open dialog lRes = Application.Dialogs(wdDialogInsertPicture).Show 'reset path Options.DefaultFilePath(Path:=wdPicturesPath) = sPath If lRes &lt;&gt; 0 And ActiveDocument.InlineShapes.Count &gt; 0 Then 'if inserted, changing the size Call PicSize(ActiveDocument.InlineShapes(ActiveDocument.InlineShapes.Count)) End If End Sub Sub PicSize(oPic As InlineShape) Dim iScale As Single Dim iWidth As Single iWidth = 200 ' (pixel) oPic.LockAspectRatio = msoTrue ' scaling iScale = (iWidth / oPic.Width) * 100 oPic.ScaleWidth = iScale oPic.ScaleHeight = iScale End Sub </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload