Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for qpro2xls.vbs

(view source code of qpro2xls.vbs as plain text)

  1. Option Explicit
  2.  
  3. Dim objFSO, objQPro
  4. Dim strExcel, strQPro
  5.  
  6. With WScript.Arguments
  7. 	If .Named.Exists("?")  Then Syntax ""
  8. 	If .Named.Count    > 0 Then Syntax "Syntax error: invalid switches"
  9. 	If .Unnamed.Count <> 1 Then Syntax "Syntax error: invalid number of arguments"
  10. 	strQPro = .Unnamed(0)
  11. End With
  12.  
  13. strExcel = Replace( strQPro, ".qpw", ".xls" )
  14.  
  15. Set objFSO = CreateObject( "Scripting.FileSystemObject" )
  16. With objFSO
  17. 	If Not .FileExists( strQPro ) Then Syntax "Error: file not found"
  18. 	If .FileExists( strExcel ) Then .DeleteFile strExcel, True
  19. End With
  20. Set objFSO = Nothing
  21.  
  22. Set objQPro = CreateObject( "QuattroPro.PerfectScript" )
  23. If Err Then Syntax "Error: cannot open Quattro Pro"
  24. With objQPro
  25. 	On Error Resume Next
  26. 	.FileOpen strQpro
  27. 	If Err Then
  28. 		Syntax "Error: cannot open file"
  29. 	Else
  30. 		.FileSaveAsExcel strExcel
  31. 		.FileClose
  32. 		If Err Then Syntax "Error: cannot save file"
  33. 	End If
  34. 	.Quit
  35. 	On Error Goto 0
  36. End With
  37. Set objQPro = Nothing
  38.  
  39.  
  40. Sub Syntax( myMsg )
  41. 	Dim strMsg
  42. 	If IsObject( objQPro ) Then objQPro.Quit
  43. 	Set objFSO  = Nothing
  44. 	Set objQPro = Nothing
  45. 	If myMsg <> "" Then strMsg = vbCrLf & myMsg & vbCrLf
  46. 	strMsg = strMsg & vbCrLf _
  47. 	       & "QPro2Xls.vbs,  Version 1.00" _
  48. 	       & vbCrLf _
  49. 	       & "Convert a Quattro Pro spreadsheet to Excel" _
  50. 	       & vbCrLf & vbCrLf _
  51. 	       & "Usage:  [ CSCRIPT ]  QPRO2XLS.VBS  qpro_file" _
  52. 	       & vbCrLf & vbCrLf _
  53. 	       & "Where:  ""qpro_file""  is the file name of the Quattro" _
  54. 	       & vbCrLf _
  55. 	       & "                     Pro spreadsheet to be converted" _
  56. 	       & vbCrLf & vbCrLf _
  57. 	       & "Notes:  Quattro Pro must be installed to use this script." _
  58. 	       & vbCrLf _
  59. 	       & "        The Excel ""target"" file will have the same name" _
  60. 	       & vbCrLf _
  61. 	       & "        and will be located in the same directory as the" _
  62. 	       & vbCrLf _
  63. 	       & "        Quattro Pro ""source"" file." _
  64. 	       & vbCrLf _
  65. 	       & "        If the Excel ""target"" file exists, it will be" _
  66. 	       & vbCrLf _
  67. 	       & "        overwritten without confirmation." _
  68. 	       & vbCrLf & vbCrLf _
  69. 	       & "Written by Rob van der Woude" _
  70. 	       & vbCrLf _
  71. 	       & "http://www.robvanderwoude.com"
  72. 	WScript.Echo strMsg
  73. 	WScript.Quit 1
  74. End Sub
  75.  

page last uploaded: 2017-04-06, 13:33