(view source code of wpsaveas.vbs as plain text)
' This script opens a WordPerfect
' document, and saves it as HTML file.
'
' Tested with Corel WordPerfect 12 only.
'
' Written by Rob van der Woude
' http://www.robvanderwoude.com
Option Explicit
WP2HTML "D:\MyFiles\MyDoc.wpd"
Sub WP2HTML( myFile )
' This subroutine opens a WordPerfect document,
' then saves it as HTML, and closes WordPerfect.
' If the HTML file exists, the subroutine will
' prompt for overwrite.
' If WordPerfect was already active, the subroutine
' will prompt the user to save the changes in other
' documents.
'
' Written by Rob van der Woude
' http://www.robvanderwoude.com
' Standard housekeeping
Dim objFSO, objWP, objWPFile, strHTMLFile, strWPFile
Const AmiPro_12_FileOpen_Format = 201
Const AmiPro_12A_FileOpen_Format = 202
Const AmiPro_12B_FileOpen_Format = 203
Const AmiPro_20_FileOpen_Format = 204
Const AmiPro_30_FileOpen_Format = 205
Const ANSIDelimitedTextWindows_FileOpen_Format = 406
Const ANSIGenericWordProcessor_Windows_FileOpen_Format = 407
Const ANSIText_Windows_FileOpen_Format = 161
Const AreAHangol_FileOpen_Format = 375
Const Aruga_23_FileOpen_Format = 396
Const ASCIIStandard_FileOpen_Format = 160
Const ASCIIStripped_FileOpen_Format = 165
Const DelimitedText_FileOpen_Format = 163
Const DisplayWrite_40_FileOpen_Format = 82
Const DisplayWrite_42_FileOpen_Format = 83
Const DisplayWrite_50_FileOpen_Format = 84
Const Excel_40_FileOpen_Format = 807
Const FFT_FileOpen_Format = 81
Const Hana_FileOpen_Format = 376
Const HTML_FileOpen_Format = 226
Const Ichitaro_3x_FileOpen_Format = 392
Const Ichitaro_4x_FileOpen_Format = 393
Const Ichitaro_5x_FileOpen_Format = 394
Const Kermit_7bit_Transfer_FileOpen_Format = 173
Const Matu_4_FileOpen_Format = 397
Const Matu_5_FileOpen_Format = 398
Const Matu_6_FileOpen_Format = 399
Const MicroSoftWord_40_FileOpen_Format = 52
Const MicroSoftWord_50_FileOpen_Format = 53
Const MicroSoftWord_55_FileOpen_Format = 54
Const MultiMate_33_FileOpen_Format = 100
Const MultiMate_40_FileOpen_Format = 103
Const MultiMateAdvantage_36_FileOpen_Format = 101
Const MultiMateAdvantageII_10_FileOpen_Format = 102
Const NavyDIF_FileOpen_Format = 175
Const OfficeWriter_60_FileOpen_Format = 120
Const OfficeWriter_611_FileOpen_Format = 122
Const OfficeWriter_61_FileOpen_Format = 121
Const OfficeWriter_62_FileOpen_Format = 123
Const P1EXE_FileOpen_Format = 395
Const RFT_FileOpen_Format = 80
Const RTF_FileOpen_Format = 150
Const RTFJ_FileOpen_Format = 391
Const SGML_FileOpen_Format = 227
Const WaiSing_251_FileOpen_Format = 380
Const WindowsWrite_FileOpen_Format = 210
Const WordForWindows_10_FileOpen_Format = 60
Const WordForWindows_11_FileOpen_Format = 61
Const WordForWindows_12_FileOpen_Format = 371
Const WordForWindows_1A_FileOpen_Format = 62
Const WordForWindows_20_FileOpen_Format = 63
Const WordForWindows_20a_FileOpen_Format = 64
Const WordForWindows_20b_FileOpen_Format = 65
Const WordForWindows_20c_FileOpen_Format = 66
Const WordForWindows_50_FileOpen_Format = 372
Const WordForWindows_60_FileOpen_Format = 67
Const WordPerfect_42_FileOpen_Format = 1
Const WordPerfect_50_FileOpen_Format = 2
Const WordPerfect_51_FileOpen_Format = 3
Const WordPerfect_5xA_FileOpen_Format = 370
Const WordPerfect_60_FileOpen_Format = 4
Const WordPerfect_6_7_8_FileOpen_Format = 4
Const WordPerfect_7_FileOpen_Format = 6
Const WordPerfect_90_FileOpen_Format = 4
Const WordPerfect_CompoundFile_FileOpen_Format = 6
Const WordStar2000_10_FileOpen_Format = 40
Const WordStar2000_20_FileOpen_Format = 41
Const WordStar2000_30_FileOpen_Format = 42
Const WordStar_331_FileOpen_Format = 31
Const WordStar_33_FileOpen_Format = 30
Const WordStar_34_FileOpen_Format = 32
Const WordStar_40_FileOpen_Format = 33
Const WordStar_50_FileOpen_Format = 34
Const WordStar_55_FileOpen_Format = 35
Const WordStar_60_FileOpen_Format = 36
Const WPS_Chinese_FileOpen_Format = 377
Const XML_UTF16Big_FileOpen_Format = 222
Const XML_UTF16Lit_FileOpen_Format = 223
Const XML_UTF8_FileOpen_Format = 224
Const XyWriteIIIPlus_355_FileOpen_Format = 190
Const XyWriteIIIPlus_356_FileOpen_Format = 191
Const AmiPro_12_FileSave_ExportType = 201
Const AmiPro_12A_FileSave_ExportType = 202
Const AmiPro_12B_FileSave_ExportType = 203
Const AmiPro_20_FileSave_ExportType = 204
Const AmiPro_30_FileSave_ExportType = 205
Const ANSIDelimitedTextWindows_FileSave_ExportType = 406
Const ANSIGeneratedWordProcessor_Windows_FileSave_ExportType = 407
Const ANSIText_Windows_FileSave_ExportType = 161
Const AreAHangol_FileSave_ExportType = 375
Const Aruga_23_FileSave_ExportType = 396
Const ASCIIStandard_FileSave_ExportType = 160
Const ASCIIStripped_FileSave_ExportType = 165
Const DelimitedText_FileSave_ExportType = 163
Const DisplayWrite_40_FileSave_ExportType = 82
Const DisplayWrite_42_FileSave_ExportType = 83
Const DisplayWrite_50_FileSave_ExportType = 84
Const EDGAR_FileSave_ExportType = 225
Const Excel_40_FileSave_ExportType = 807
Const FFT_FileSave_ExportType = 81
Const Hana_FileSave_ExportType = 376
Const HTML_FileSave_ExportType = 226
Const Ichitaro_3x_FileSave_ExportType = 392
Const Ichitaro_4x_FileSave_ExportType = 393
Const Ichitaro_5x_FileSave_ExportType = 394
Const Kermit_7bit_Transfer_FileSave_ExportType = 173
Const Matu_4_FileSave_ExportType = 397
Const Matu_5_FileSave_ExportType = 398
Const Matu_6_FileSave_ExportType = 399
Const MicroSoftWord_40_FileSave_ExportType = 52
Const MicroSoftWord_50_FileSave_ExportType = 53
Const MicroSoftWord_55_FileSave_ExportType = 54
Const MultiMate_33_FileSave_ExportType = 100
Const MultiMate_40_FileSave_ExportType = 103
Const MultiMateAdvantage_36_FileSave_ExportType = 101
Const MultiMateAdvantageII_10_FileSave_ExportType = 102
Const NavyDIF_FileSave_ExportType = 175
Const OfficeWriter_60_FileSave_ExportType = 120
Const OfficeWriter_611_FileSave_ExportType = 122
Const OfficeWriter_61_FileSave_ExportType = 121
Const OfficeWriter_62_FileSave_ExportType = 123
Const P1EXE_FileSave_ExportType = 395
Const QuattroPro_30_FileSave_ExportType = 836
Const QuattroPro_40_FileSave_ExportType = 837
Const RFT_FileSave_ExportType = 80
Const RTF_FileSave_ExportType = 150
Const RTFJ_FileSave_ExportType = 391
Const SGML_FileSave_ExportType = 227
Const WaiSing_251_FileSave_ExportType = 380
Const WindowsWrite_FileSave_ExportType = 210
Const WordForWindows_10_FileSave_ExportType = 60
Const WordForWindows_11_FileSave_ExportType = 61
Const WordForWindows_12_FileSave_ExportType = 371
Const WordForWindows_1A_FileSave_ExportType = 62
Const WordForWindows_20_FileSave_ExportType = 63
Const WordForWindows_20a_FileSave_ExportType = 64
Const WordForWindows_20b_FileSave_ExportType = 65
Const WordForWindows_20c_FileSave_ExportType = 66
Const WordForWindows_50_FileSave_ExportType = 372
Const WordForWindows_60_FileSave_ExportType = 67
Const WordPerfect_42_FileSave_ExportType = 1
Const WordPerfect_50_FileSave_ExportType = 2
Const WordPerfect_51_FileSave_ExportType = 3
Const WordPerfect_5xA_FileSave_ExportType = 370
Const WordPerfect_60_FileSave_ExportType = 4
Const WordPerfect_6_7_8_FileSave_ExportType = 4
Const WordPerfect_7_FileSave_ExportType = 6
Const WordPerfect_90_FileSave_ExportType = 4
Const WordPerfect_CompoundFile_FileSave_ExportType = 6
Const WordStar2000_10_FileSave_ExportType = 40
Const WordStar2000_20_FileSave_ExportType = 41
Const WordStar2000_30_FileSave_ExportType = 42
Const WordStar_331_FileSave_ExportType = 31
Const WordStar_33_FileSave_ExportType = 30
Const WordStar_34_FileSave_ExportType = 32
Const WordStar_40_FileSave_ExportType = 33
Const WordStar_50_FileSave_ExportType = 34
Const WordStar_55_FileSave_ExportType = 35
Const WordStar_60_FileSave_ExportType = 36
Const WPS_Chinese_FileSave_ExportType = 377
Const XML_UTF16Big_FileSave_ExportType = 222
Const XML_UTF16Lit_FileSave_ExportType = 223
Const XML_UTF8_FileSave_ExportType = 224
Const XyWriteIIIPlus_355_FileSave_ExportType = 190
Const XyWriteIIIPlus_356_FileSave_ExportType = 191
Const No_FileSave_Overwrite = 0
Const Prompt_FileSave_Overwrite = 2
Const Yes_FileSave_Overwrite = 1
Const vbBinaryCompare = 0
Const vbTextCompare = 1
' Create a File System object
Set objFSO = CreateObject( "Scripting.FileSystemObject" )
' Create a WordPerfect OLE Automation object
Set objWP = CreateObject( "WordPerfect.PerfectScript" )
With objWP
' Check if the WordPerfect file exists
If objFSO.FileExists( myFile ) Then
Set objWPFile = objFSO.GetFile( myFile )
Else
WScript.Echo "FILE OPEN ERROR: The file does not exist" & vbCrLf
' Close WordPerfect
.ExitWordPerfect
Exit Sub
End If
strWPFile = objWPFile.Path
strHTMLFile = objFSO.BuildPath( objWPFile.ParentFolder, Left( objWPFile.Name, Len( objWPFile.Name ) - 3 ) & "html" )
' Maximize the window
.AppMaximize
' Open the document
On Error Resume Next
.FileOpen strWPFile, WordPerfect_6_7_8_FileOpen_Format
If Err Then
WScript.Echo "FILE OPEN ERROR: " & Err.Number & vbCrLf & Err.Description & vbCrLf
Err.Clear
' Close WordPerfect
.ExitWordPerfect
Exit Sub
End If
' Save the document as HTML file
.FileSave strHTMLFile, HTML_FileSave_ExportType, Prompt_FileSave_Overwrite
If Err Then
WScript.Echo "FILE SAVE AS ERROR: " & Err.Number & vbCrLf & Err.Description & vbCrLf
Err.Clear
End If
' Close WordPerfect
.ExitWordPerfect
If Err Then
WScript.Echo "PROGRAM CLOSE ERROR: " & Err.Number & vbCrLf & Err.Description & vbCrLf
Err.Clear
End If
On Error Goto 0
End With
' Release the object
Set objWP = Nothing
End Sub
page last modified: 2024-04-16; loaded in 0.0126 seconds