when i try to run the following code i get a runtime error 1004 "Unable to set active printer property of the application class" at the line "ExcelObject.ActivePrinter = "\\WS149.Logitech.local\DYMO LabelManager PC" ".
The code is meant to open an excel sheet, add a template and put some numbers in, print to the label printer(which is not the default printer) and then close again. if i leave this problem line out it works fine but prints to the default printer. Any ideas anyone?
Dim ExcelObject As Object
Dim XLSheet As Object
If (FindWindow(lpClassName, 0&) = 0) And (YesNo = vbYes) Then 'check if excel is not open
Set ExcelObject = CreateObject("excel.application")
ExcelObject.Visible = True
ExcelObject.Workbooks.Add (LOGIGOODS_LABEL_TEMPLATE)
Set XLSheet = ExcelObject.Application.ActiveWorkbook.ActiveSheet
For I = 1 To NoOfLabels
With XLSheet
.Cells(1, I).Value = "IG:" & Me.IGNo
.Cells(2, I).Value = "Job:" & Me.JobNo
End With
Next I
ExcelObject.ActivePrinter = "\\WS149.Logitech.local\DYMO LabelManager PC"
XLSheet.PrintOut
ExcelObject.Application.ActiveWorkbook.Close SaveChanges:=False
ExcelObject.Application.Quit
Thanks
Anthony
The code is meant to open an excel sheet, add a template and put some numbers in, print to the label printer(which is not the default printer) and then close again. if i leave this problem line out it works fine but prints to the default printer. Any ideas anyone?
Dim ExcelObject As Object
Dim XLSheet As Object
If (FindWindow(lpClassName, 0&) = 0) And (YesNo = vbYes) Then 'check if excel is not open
Set ExcelObject = CreateObject("excel.application")
ExcelObject.Visible = True
ExcelObject.Workbooks.Add (LOGIGOODS_LABEL_TEMPLATE)
Set XLSheet = ExcelObject.Application.ActiveWorkbook.ActiveSheet
For I = 1 To NoOfLabels
With XLSheet
.Cells(1, I).Value = "IG:" & Me.IGNo
.Cells(2, I).Value = "Job:" & Me.JobNo
End With
Next I
ExcelObject.ActivePrinter = "\\WS149.Logitech.local\DYMO LabelManager PC"
XLSheet.PrintOut
ExcelObject.Application.ActiveWorkbook.Close SaveChanges:=False
ExcelObject.Application.Quit
Thanks
Anthony