VBA:PublishPDF Use Corel WordPerfect to convert WP documents to PDF
The solution for “VBA:PublishPDF Use Corel WordPerfect to convert WP documents to PDF” can be found here. The following code will assist you in solving the problem.
Option Explicit
Dim blnExitWP, colItems, strMsg, strPDFDoc, strWPDoc
Dim objFSO, objItem, objWMIService, objWP
strMsg = “”
‘ Open a FileSystem Object
Set objFSO = CreateObject( “Scripting.FileSystemObject” )
‘ Parse the command line arguments
With WScript.Arguments
If .Named.Count > 0 Then Syntax
Select Case .Unnamed.Count
Case 1
strWPDoc = .Unnamed(0)
‘ No PDF file name specified, so we’ll take the location and
‘ file name of the WordPerfect document and append a PDF extension
strPDFDoc = objFSO.BuildPath( objFSO.GetParentFolderName( strWPDoc ), _
objFSO.GetBaseName( strWPDoc ) & “.pdf” )
Case 2
strWPDoc = .Unnamed(0)
strPDFDoc = .Unnamed(1)
Case Else
Syntax
End Select
End With
‘ Check if the WordPerfect file exists
If Not objFSO.FileExists( strWPDoc ) Then
strMsg = “ERROR: File “”” & strWPDoc & “”” not found” & vbCrLf & vbCrLf
Syntax
End If
‘ Check if WordPerfect is already active by
‘ searching for a process named WPWIN**.EXE
blnExitWP = True
Set objWMIService = GetObject( “winmgmts://./root/cimv2” )
Set colItems = objWMIService.ExecQuery( “SELECT * FROM Win32_Process” )
For Each objItem In colItems
If Left( UCase( objItem.Name ), 5 ) = “WPWIN” And _
Right( UCase( objItem.Name ), 4 ) = “.EXE” And _
Len( objItem.Name ) < 12 Then blnExitWP = False
Next
Set objWMIService = Nothing
' Create a new WP OLE Automation object
Set objWP = CreateObject( "WordPerfect.PerfectScript" )
With objWP
' Open the specified document
.FileOpen( strWPDoc )
' Publish to PDF
.PdfDlg( strPDFDoc )
' Close the document
.Close
' Close WordPerfect unless it was already active
If blnExitWP Then .ExitWordPerfect
End With
' Release the objects
Set objFSO = Nothing
Set objWP = Nothing
Sub Syntax( )
strMsg = strMsg & vbCrLf _
& WScript.ScriptName & ", Version 1.00" & vbCrLf _
& "Convert a WordPerfect document to Adobe PDF" & vbCrLf & vbCrLf _
& "Usage: " & UCase( WScript.ScriptName ) _
& " wpdoc_filename [ pdf_filename ]" & vbCrLf & vbCrLf _
& "Where: ""wpdoc_filename"" is the WP file to be converted" _
& vbCrLf _
& " ""pdf_filename"" is the name for the PDF file" _
& vbCrLf _
& " " _
& "(default is name of WP file with .PDF extension)" _
& vbCrLf & vbCrLf _
& "Written by Rob van der Woude" & vbCrLf _
& "http://www.robvanderwoude.com"
WScript.Echo strMsg
WScript.Quit(1)
End Sub
More questions on [categories-list]
- checking and changing system volume vb.net checking and changing system volume vb.net
- selecttoken em vbnet e json
- how to call gcd in vba
- pivot data source not accepting table named range vba
- Excel PasteSpecial Format:= can’t find the argument
- refresh token em vb net
- menus act like radio buttons vb.net
- power query M substract minimum value of column -dax
- how to concatenate more than 40 lines in vba how to concatenate more than 40 lines in vba
- discern between file and folder given path vb.net
- putting marquee in vb.net
- code for reading letters only in vb 6
- vba array dimensions
- text to speech vb.net
- set datetimepicker value to null vb
- how to correct a number to 2 decimal places in vba
- System.Data.OleDb.OleDbException: ‘No value given for one or more required parameters.’
- vba file chooser
- vba code to add new column in table
- how save excel through visual basic
- make your computer talk vbscript
- for i in range vba
- vbnet make a string to unicode converter
- create new worksheet excel visual basic
- vba sendkeys
- vba is integer
- remove series name from legendvbnet
- priavte sub with multiple handels find sneder
- openfiledialog specific folder
- vbnet check if string is only symbols
- tester si une case est vide vba
- vbnet check if number is even or odd
- find days in month vba
- excel vba multiply cell value
- sort dictionary by key vba
- excel vba delete columns in range excel vba delete columns on another sheet
- VBA – Print Whole Workbook VBA – Print Whole Workbook
- excel vba formatconditions range
- VBA Dictionary Data Type
- excel vba assign shortcut key to button
- vba comment shortcut vba comment shortcut
- build an index all files of a FTP site
- vbnet find highest value in chart
- vb net dgv doesn’t keep currency format
- delete all controls from list of control vb.net delete all controls in an area vb
- vlookup columns not next to each other
- how to get value from clipboard in vbnet
- afficher un message d’erreur vba
- VBA Sort RossetaCode
- vba string length