Aleksandr Matuzov

Paste image to doc file through docx=>pdf convertation

Discussion created by Aleksandr Matuzov on Jan 14, 2019
Latest reply on Jan 25, 2019 by Paul Wyndham

Hello guys. We had tasks to automatically add manager signature for approved documents. We often write orders to communicate with other departments. After we starting use PDM we began saving our orders in PDM. We make @simple Workflow, where 3 states: Start, Deleted and Approved. An engineer writes text for order save this doc then print it and give it to the manager for approving by signature. After that order is approving in PDM. This action`s a little bit annoying and we make changes to standard task convert doc to pdf:

        Dim imageFullPath As String
        Dim FindText As String
        Dim objDoc, objRange As Object

        imageFullPath = "D:\PDM\Library PDM\Sign.png"
        FindText = "Manager sign"
        objDoc = wordApp.ActiveDocument
        objRange = wordApp.ActiveDocument.Range
        With objRange
            With .Find
                .Text = FindText
                ' Loop until Word can no longer
                ' find the search string, inserting the specified image at each location
                Do While .Execute
                    objRange.Move(Unit:=1, Count:=15)
                    objRange.InlineShapes.AddPicture(FileName:=imageFullPath, LinkToFile:=False, SaveWithDocument:=True)
            End With
        End With



This code takes a PNG picture from PDM with the scanned signature. And before make PDF inserts it to DOC file after word: "Manager sign". This code should be pasted after line 122:

        'Log("Open document")
        Dim docPath As Object = ""
        docPath = Path.Combine("<SourceFolderPath>", "<SourceFileName>")

        If IsProtected(docPath) Then
            Log("The document " & docPath & " is protected, it cannot be handled by the addin.")
            Return False
        End If

        Dim doc As Object = wordApp.Documents.Open(docPath)


Past here