troubleshooting Question

Erro 429: ActiveX control cannot create object

Avatar of inversojvo
inversojvoFlag for Germany asked on
Microsoft AccessVisual Basic ClassicWeb Components
5 Comments1 Solution754 ViewsLast Modified:

I use Access 2000 (Windows XP) with Microsoft ActiveX Data Objects Recordset 2.8 and try to get printer properties (default printer) with the following code:

Public Sub getUserDefaultPrinter()

    Dim hPrinter As Long
    Dim dm As DEVMODE
    Dim sPrinterName As String
    Dim yDevModeData() As Byte
    Dim iRet As Long
    Dim Orientation As Long
    Dim PaperSize As Long
    Dim PaperLength As Long
    Dim DefaultSource As Long
    Dim PrintQuality As Long

   On Error GoTo getUserDefaultPrinter_Error
   'get the name of the current printer
   sPrinterName = Trim$(Left$(ActivePrinter, InStr(ActivePrinter, " on ")))
  pd.DesiredAccess = PRINTER_ALL_ACCESS
    'Get the printer handle
  iRet = OpenPrinter(sPrinterName, hPrinter, pd)
  If (iRet = 0) Or (hPrinter = 0) Then
     'Couldn't access the printer
      Exit Sub
  End If

  'Find out how many bytes needed for the printer properties
  iRet = DocumentProperties(0, hPrinter, sPrinterName, dm, dm, DM_IN_BUFFER)

  'Make sure the byte array is large enough, including the
  '100 bytes extra in case the printer driver is lying.
  ReDim yDevModeData(0 To iRet + 100) As Byte
  'Load the printer properties into the byte array
  iRet = DocumentProperties(0, hPrinter, sPrinterName, dm, dm, DM_IN_BUFFER)
  'Copy the byte array to the DEVMODE structure
  Call CopyMemory(dm, yDevModeData(0), Len(dm))

    'ifi: Globales Objekt initialisieren
  If IsNull(gobjUserDefaultPrinter) Or gobjUserDefaultPrinter Is Nothing Then
    Set gobjUserDefaultPrinter = New clsStandardDrucker
  End If
  'Get the value of the requested property
  gobjUserDefaultPrinter.Name = sPrinterName
  gobjUserDefaultPrinter.DefaultSource = dm.dmDefaultSource
   On Error GoTo 0
   Exit Sub

and get the following error because of the line "sPrinterName = Trim$(Left$(ActivePrinter, InStr(ActivePrinter, " on ")))":

Error 429: ActiveX control cannot create object.

I really do not know why. It worked already and I have not change anything.

Many thanks for your help!

Have a nice day!


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros