0

I have a VBScript that converts Excel files to Tab delimited text files:

format = -4158

Set objFSO = CreateObject("Scripting.FileSystemObject")

src_file = objFSO.GetAbsolutePathName(Wscript.Arguments.Item(0))
dest_file = objFSO.GetAbsolutePathName(WScript.Arguments.Item(1))

Dim oExcel
Set oExcel = CreateObject("Excel.Application")

oExcel.DisplayAlerts = False
oExcel.ProtectedViewWindows.Open(src_file)
oExcel.ActiveProtectedViewWindow.Edit

Dim oBook
Set oBook = oExcel.Workbooks.Open(src_file)

oBook.Worksheets(5).Activate

oBook.SaveAs dest_file, format

oBook.Close False
oExcel.DisplayAlerts = True
oExcel.Quit

In Qt I use wscript to run this code and have connected the signal QProcess::errorOccurred to a lambda:

QObject::connect(&wscript, &QProcess::errorOccurred, [=](QProcess::ProcessError error)
{

  qDebug() << "Error has occured";

});

In my VB script, Protected View is removed. However, I modified the script so that it would not disable the protected view. This results in my script not being able to open Excel files that are in protected view, which results in an error saying the Excel file cannot be opened. However, the errorOccured signal is never sent. Why is this happening?

Dillydill123
  • 693
  • 7
  • 22

1 Answers1

3

The Process::errorOccured signal is only emitted if the QProcess itself has problems or if the process it's running crashes (see the reasons here).

If you want your VB script to notify your app of an error in some way then your script will have to either use a non-zero exit code which can be read via QProcess::exitCode or, write to its standard error stream which can be caught and read on the QProcess::readyReadStandardError signal.

G.M.
  • 12,232
  • 2
  • 15
  • 18