I have the following macro that gives me a BASIC runtime error on ThisComponent.getPrinter() . Property or method not found: getPrinter.
If I save the macro as part of the document it work fine.
Sub PrintD1
Dim oDoc
oDoc = ThisComponent.getPrinter()
oDoc(0).Value = "\\DC1.illinoiseyecenter.com\D1"
ThisComponent.setPrinter(oDoc)
ThisComponent.StyleFamilies.getByName("PageStyles").getByName("Default").PrinterPaperTray = " Tray 3"
Dim oOpts(0) As New com.sun.star.beans.PropertyValue
oOpts(0).Name = "Wait"
oOpts(0).Value = False
ThisComponent.Print(oOpts())
End Sub
Yes I do. So in the macro Organizer I currently have it installed under My Macros. If I create the macro under the document Router.odt->Standard it works.
There must be something I am not calling to get the attachment to the current document.
I read thru the Accessing the UNO API information and put in "MsgBox ThisComponent.Dbg_SupportedInterfaces" it returns with Dbg_SupportedInterface not available. (TypeClass is not TypeClass_INTERFACE)
So I figured out the error that is going on. Apparently when I am debugging the macro it does not recognize the document if it is under my macros.
If I just run the macro it works. I will just debug the macro as part of the document.
Thanks for looking into it.
When the code is stored in the global scope ("My Documents" or "OpenOffice Macros"), ThisComponent refers to the latest active document, not counting the Basic IDE but counting any help window.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Macros like yours that reference ThisComponent multiple times can cause problems especially during debugging.
That situation can easily be avoided if you begin your macro as Andrew Pitonyak recommends with
Then you use oDoc throughout your macro without any chance of it changing references.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
I made that change in the code, during the testing I figured out what the main issue is.
When trying to set the paper tray it tells me the Tray is basically invalid. Even though the tray is valid for the printer i set it to in the previous statement it for some odd reason thinks I am hooked up to my "Default" printer which does not have a "Tray 3". Is there anyway to force the document to check the printer i have changed it to?