Good Day B4Xers,
I am using the provided example with XLUtils and trying to create a pdf from the generated Word document but I am getting a constant error which I cannot resolve:
Here is the code I am using:
and the error I am getting:
My Setup:
Dell G3 i7 running windows 11
javac - C:\Program Files\Java\jdk-14.0.1\bin\javac.exe
B4J - Version 9.30
Thanks in Advance for the help
I am using the provided example with XLUtils and trying to create a pdf from the generated Word document but I am getting a constant error which I cannot resolve:
Here is the code I am using:
XLUtils Word Example:
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1")
MainForm.Show
WD.Initialize
xui.SetDataFolder("Reports")
Dim n As Long = DateTime.Now
Dim doc As WordDocument = CreateDocument
Dim f As String = doc.SaveAs(xui.DefaultFolder, "Report.docx", True)
Log(DateTime.Now - n)
Log($"Document saved: ${f}"$)
'if MS Word is installed:
Label1.Text = "Creating PDF..."
'this step can be a bit slow. Comment it during development.
Wait For (WD.PowerShellConvertToPdf(File.Combine(xui.DefaultFolder, "Report.docx"), File.Combine(xui.DefaultFolder, "Report.pdf"), True)) Complete (Success As Boolean)
Label1.Text = "Opening word"
Wait For (WD.OpenWord(f)) Complete (Success As Boolean)
Label1.Text = "Report created: " & f
AnotherProgressBar1.Visible = False
End Sub
and the error I am getting:
Code:
, RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At line:1 char:154
+ ... rt.docx'); $document.SaveAs([ref] 'C:\Users\******\AppData\Roami ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At line:1 char:249
+ ... \Roaming\Reports\Report.pdf', [ref] 17); $document.Close();$objWor ...
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Exception calling "Quit" with "0" argument(s): "Unable to cast COM object of type
'Microsoft.Office.Interop.Word.ApplicationClass' to interface type 'Microsoft.Office.Interop.Word._Application'. This
operation failed because the QueryInterface call on the COM component for the interface with IID
'{00020970-0000-0000-C000-000000000046}' failed due to the following error: Error loading type library/DLL. (Exception
from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY))."
At line:1 char:267
+ ... Reports\Report.pdf', [ref] 17); $document.Close();$objWord.Quit()}
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidCastException
My Setup:
Dell G3 i7 running windows 11
javac - C:\Program Files\Java\jdk-14.0.1\bin\javac.exe
B4J - Version 9.30
Thanks in Advance for the help