Skip to main content

Hi,

I’ve been trying out a document macro to create a PDF when checking in a word-document.

Below process

  1. Create a new document revision for the document class associated with the macro
  2. Click “Check In Document” and select a word-document
  3. Click “Edit Document”, save and close it
  4. Click “Check In Document”

Above process successfully creates a PDF-file and checks it in together with the edited word-document.

My question is, is it possible to skip step 3 and 4? That is, have the PDF-file created and checked in at at the first time I click “Check In Document”?

Currently I’ve been able to have the macro create a PDF file at step 2, but IFS doesn’t check it in. The PDF-file is created in the CHECK_IN_PATH folder with the same file name as the word-document.

I understand that sFileName and sPath below is null when doing step 2 above but contains LOCAL_FILE_NAME and LOCAL_PATH when I’ve first checked out the document as per step 3.

'Macro Block: WORD_INIT_AND_COMMON
' General declarations for MS Word macros
'
Dim oWord
Dim oDoc
Dim sFileName
Dim sPath
Dim sSavePath
Dim sPathNew
Dim oCliMgr
Dim bVisible
Const wdDoNotSaveChanges = 0

Public Sub Open_Word(bVisible)
On Error Resume Next

sFileName = ScriptValues.Item("LOCAL_FILE_NAME").Value
sPath = ScriptValues.Item("LOCAL_PATH").Value

If sFileName = "" Then
sFileName = ClientScriptValues.Item("LOCAL_FILE_1").Value
End If

If sPath = "" Then
sPath = ClientScriptValues.Item("CHECK_IN_PATH").Value
End If

If Not Right(sPath, 1) = "\" Then
sPath = sPath & "\"
End If

Set oWord = CreateObject("Word.Application")
oWord.Visible = bVisible
Set oDoc = oWord.Documents.Open(sPath & sFileName)

End Sub
'Macro Block: WORD_CHECKIN
Public Sub CheckIn_Word()
On Error Resume Next
bVisible = False
Open_Word bVisible
Generate_PDF
oWord.NormalTemplate.Saved = True 'To avoid prompt regarding "Save changes to Normal.dotx"
oWord.Quit wdDoNotSaveChanges
Set oWord = Nothing
End Sub
'Macro Block: WORD_GENERATE_PDF
Public Sub Generate_PDF()

On Error Resume Next

oWord.ActiveDocument.ExportAsFixedFormat sPath & Replace(sFileName, ".DOCX", ".PDF", 1, -1, 1), 17, False, 0 , 0, , , 0, False, True, 0, False, True, True

End Sub

This is done in IFS Cloud 25.1.4 but I thinks it applicable for most versions.

Be the first to reply!