Rob van der Woude's Scripting Pages
(sponsored link)
WordPerfect Office X4 Get the latest
WordPerfect Office Suite

 

VBScript Scripting Techniques > OLE Automation > Quattro Pro

Automate Quattro Pro

  1. QPro2Xls: convert Quattro Pro spreadsheets to Excel

 

QPro2Xls
Use Quattro Pro to convert Quattro Pro spreadsheets to Excel
VBScript Code:
Option Explicit

Dim objFSO, objQPro
Dim strExcel, strQPro

With WScript.Arguments
    If .Named.Exists("?")  Then Syntax ""
    If .Named.Count    > 0 Then Syntax "Syntax error: invalid switches"
    If .Unnamed.Count <> 1 Then Syntax "Syntax error: invalid number of arguments"
    strQPro = .Unnamed(0)
End With

strExcel = Replace( strQPro, ".qpw", ".xls" )

Set objFSO = CreateObject( "Scripting.FileSystemObject" )
With objFSO
    If Not .FileExists( strQPro ) Then Syntax "Error: file not found"
    If .FileExists( strExcel ) Then .DeleteFile strExcel, True
End With
Set objFSO = Nothing

Set objQPro = CreateObject( "QuattroPro.PerfectScript" )
If Err Then Syntax "Error: cannot open Quattro Pro"
With objQPro
    On Error Resume Next
    .FileOpen strQpro
    If Err Then
        Syntax "Error: cannot open file"
    Else
        .FileSaveAsExcel strExcel
        .FileClose
        If Err Then Syntax "Error: cannot save file"
    End If
    .Quit
    On Error Goto 0
End With
Set objQPro = Nothing


Sub Syntax( myMsg )
    Dim strMsg
    If IsObject( objQPro ) Then objQPro.Quit
    Set objFSO  = Nothing
    Set objQPro = Nothing
    If myMsg <> "" Then strMsg = vbCrLf & myMsg & vbCrLf
    strMsg = strMsg & vbCrLf _
           & "QPro2Xls.vbs,  Version 1.00" _
           & vbCrLf _
           & "Convert a Quattro Pro spreadsheet to Excel" _
           & vbCrLf & vbCrLf _
           & "Usage:  [ CSCRIPT ]  QPRO2XLS.VBS  qpro_file" _
           & vbCrLf & vbCrLf _
           & "Where:  ""qpro_file""  is the file name of the Quattro" _
           & vbCrLf _
           & "                     Pro spreadsheet to be converted" _
           & vbCrLf & vbCrLf _
           & "Notes:  Quattro Pro must be installed to use this script." _
           & vbCrLf _
           & "        The Excel ""target"" file will have the same name" _
           & vbCrLf _
           & "        and will be located in the same directory as the" _
           & vbCrLf _
           & "        Quattro Pro ""source"" file." _
           & vbCrLf _
           & "        If the Excel ""target"" file exists, it will be" _
           & vbCrLf _
           & "        overwritten without confirmation." _
           & vbCrLf & vbCrLf _
           & "Written by Rob van der Woude" _
           & vbCrLf _
           & "http://www.robvanderwoude.com"
    WScript.Echo strMsg
    WScript.Quit 1
End Sub
Requirements:
Windows version: any
Network: any
Client software: Quattro Pro
Script Engine: any (except of course the WScript.Echo command at the end)
Summarized: Works in any Windows version, as long as Quattro Pro is installed.
 
[Back to the top of this page]

page last uploaded: 2016-09-19, 14:57