1. Tracy Lamb
  2. PowerBuilder
  3. Wednesday, 22 June 2022 16:46 PM UTC

Hi all,

I'm trying to print to a Brother label printer from my PB App.  Everything is fine until I execute iDoc.PrintOut() function (iDoc is the OLEObject).  The function keeps returning the same error (Error 11 - Printer not supported).  But I can print a label from Brother's own PTouch Editor Software.  I'm sure the ole objects are working right because prior to the PrintOut, I loop through all the objects on the ole document and fill in variables as needed.  

Here's my code:

// Set all of the fields, then print
li_max = iDoc.Objects.Count()

// Change the text values
for li_count = 1 to li_max
ls_name = iDoc.Objects[ li_count - 1 ].Name
CHOOSE CASE upper(ls_name)
  CASE "WO#"
      iDoc.Objects[ li_count - 1 ].Text = string(dw_label.GetItemNumber(1,"workorder_id"))
    iDoc.Objects[ li_count - 1 ].Text = dw_label.GetItemString(1,"instrument_id")
    iDoc.Objects[ li_count - 1 ].Text = string(dw_label.GetItemDateTime(1,"cal_date"), "mm/dd/yyyy")
    if NOT IsNull( dw_label.GetItemDateTime(1,"cal_due") ) then
      iDoc.Objects[ li_count - 1 ].Text = string(dw_label.GetItemDateTime(1,"cal_due"), "mm/dd/yyyy")
      iDoc.Object[ li_count - 1 ].Text = "NPCR"
    end if

// Set the printer
idoc.SetPrinter(is_printer, FALSE)
// Print setting start
if ( idoc.StartPrint("Cal Label", 0) = false) then
  MessageBox("idoc.StartPrint", "Failure", Information!)
  istr_parms.canceled = true
end if

lb_rc = idoc.PrintOut(1,0)   --- Error here
if lb_rc = false then
  MessageBox("Print Out", "Failure", Information!)
  MessageBox("Print Out", "Document Error Code: " + string(idoc.ErrorCode) )   --- Code 11, Printer not supported
  MessageBox("Print Out", "Printer Error Code: " + string(iPrinter.ErrorCode ) )
  MessageBox("Print Out", "Printer Error string: " + string(iPrinter.ErrorString ) )
  istr_parms.canceled = true
end if

I don't know what driver it's calling, or even how to find out what driver is installed on my machine.  Could this be related to the fact the fact that my operating system is Windows 10 64-bit and PB21 is 32-bit?  I'm also wondering if I'm supposed to define a Global Function?  If so, what function?  Total confusion over here in developer land... 


Andreas Mykonios Accepted Answer Pending Moderation
  1. Thursday, 23 June 2022 09:26 AM UTC
  2. PowerBuilder
  3. # 1


If you haven't read the following links, take a look.

printing - Brother Label Printer SDK bPac 3.1 Failed to print - Stack Overflow

b-PAC Operating Environment | Application development tool for Windows: b-PAC | Information for Developers | Brother

Some printers do support only the 32-bit sdk.

Also in the first link, from stack overflow, it's mentioned that such an issue may be related to the driver installed. Of course this conversation is 8 years old.

Don't know if it will help you. I don't have a brother printer to test your code.


  1. Tracy Lamb
  2. Thursday, 23 June 2022 15:12 PM UTC
I searched Brother first and Stack Overflow next, then Appeon Q&A. I found the same thread on Stack Overflow, and tried as much of what's in there as possible. (The thread is pretty old!) I contacted Brother support a few minutes ago, via online chat. They said this is a known issue with the latest versions/updates of Windows.

  1. Helpful 1
  1. Andreas Mykonios
  2. Friday, 24 June 2022 07:33 AM UTC
Well. So they don't give any workaround? I guess that even a vbs srcipt fails if that is the case.

  1. Helpful
There are no comments made yet.
Tracy Lamb Accepted Answer Pending Moderation
  1. Wednesday, 22 June 2022 21:36 PM UTC
  2. PowerBuilder
  3. # 2

I have both 32-bit and 64-bit versions of the b-pac utility from Brother installed. (Re-booted my machine.)  I don't know why all the other COM calls are working, but not PrintOut().  I checked PB Object Browser... didn't see anything remotely related to Brother, or b-pac, or label printer...

Do I need to declare a global external function to use a COM server?




  1. John Fauss
  2. Wednesday, 22 June 2022 22:04 PM UTC
No. ConnectToNewObject should be all that you need. Is there a website URL for the Brother PTouch Editor software? Any documentation on using the COM object that they provide? What is the classname value you specify in the ConnectToNewObject PowerScript function call?
  1. Helpful
  1. Tracy Lamb
  2. Thursday, 23 June 2022 15:15 PM UTC
The Class name is bpac.Document

  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Wednesday, 22 June 2022 18:41 PM UTC
  2. PowerBuilder
  3. # 3

Check the "OLE" tab in the PB Object Browser, find the Brother OLE object and see what info it tells you.

Are you running the app from the IDE or from a compiled exe? If compiled, as a 32-bit or 64-bit process?

If you have any of the Windows SDK's installed on your development machine, you can try using the oleview.exe utility. I'm not familiar with it, but someone in the Q&A forum recently mentioned using this to help investigate a question regarding OLE. It appears to have Help and I'm sure there is information online about what it can do and how to use it.

There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 22 June 2022 17:20 PM UTC
  2. PowerBuilder
  3. # 4

Hi Tracy;

  Sounds like the issue is with the "iDoc" OLE object. I would contact the OLE vendor for this issue.

Regards .. Chris

  1. Tracy Lamb
  2. Thursday, 23 June 2022 15:16 PM UTC
I contacted Brother today via online chat... they said this is a known issue and asked me to get back in touch with them next week. Lol!
  1. Helpful
There are no comments made yet.
  • Page :
  • 1

There are no replies made for this question yet.
However, you are not allowed to reply to this question.