In the code that we have written for printing to our printer for some reason I keep getting an error message on "line 27 which is (oPrintMgr.Printer = PrinterSelect) or on "line 29" which is (oPrintMgr.ColorMode = kPrintDefaultColorMode) but I posted the section in case there is something I am missing. This started when IT changed the name of our printers and the path where they were located. I updated all that as our form wasn't working but now those errors are popping up.
Dim oPrintMgr As PrintManager oPrintMgr = oDocument.PrintManager 'specify your printer name oPrintMgr.Printer = PrinterSelect oPrintMgr.ColorMode = kPrintDefaultColorMode oPrintMgr.Orientation = kLandscapeOrientation oPrintMgr.Scalemode = kCustomScale oPrintMgr.ScaleMode = PrintScaleModeEnum.kPrintBestFitScale oPrintMgr.PaperSize = SizePaper
Solved! Go to Solution.
Solved by A.Acheson. Go to Solution.
Hi @kroweJ56Y9
It sounds like the printer name isn’t correct? Can you confirm the string value is right. Maybe check against the actual printer name when manually printing.
Yes the print name is correct. I'll be completely honest I don't know very much about all this I'm just kind of muddling my way through. The guy that worked on all this, left the company and I've been trying to fix stuff/keep it updated. This is just being a thorn in my side.
I don’t use this type of code either so I am asking questions so hopefully another can spot the error. Can you show the whole code your using? This is only showing a partial code and not enough to do any testing.
Hi @kroweJ56Y9. It is very difficult, if not impossible, to debug code when we do not have access to the whole code. For instance, what does 'PrinterSelect' represent, and what does 'SizePaper' represent in that code example. It does not have any quotation marks around it, so it looks like either a local variable, or possibly the name of a Function routine that is supposed to return a String, or the unquoted name of a local parameter representing a text type UserParameter. I also highly recommend that you include the names of those Enums, before the Enum variations, when setting those property values. When writing code in VBA, it encourages us to only include the textual Enum variation, but in iLogic & vb.net, we are supposed to include the name of the Enum, before the name of the Enum variation.
Also, if this is a drawing (not a part or assembly) you are trying to print from, then you should 'declare' the variable's Type as DrawingPrintManager, not just as PrintManager, that way you have access to more specific properties, related to printing drawings. The value of the PrintManager.PaperSize property is supposed to be a variation of the PaperSizeEnum, so if your 'SizePaper' variable does not represent that, it will likely not work either.
Dim oPrintMgr As DrawingPrintManager = oDocument.PrintManager
'specify your printer name
oPrintMgr.Printer = PrinterSelect '???
oPrintMgr.ColorMode = Inventor.PrintColorModeEnum.kPrintDefaultColorMode
oPrintMgr.Orientation = Inventor.PrintOrientationEnum.kLandscapeOrientation
'oPrintMgr.ScaleMode = Inventor.PrintScaleModeEnum.kPrintCustomScale
oPrintMgr.ScaleMode = Inventor.PrintScaleModeEnum.kPrintBestFitScale
oPrintMgr.PaperSize = SizePaper 'Inventor.PaperSizeEnum.kPaperSizeLetter
Just some additional thoughts / ideas to help figure this out for you.
Wesley Crihfield
(Not an Autodesk Employee)
I was a space off in the print name... Fixed that and everything worked as it should. Thank you everyone for your assistance!!
Can't find what you're looking for? Ask the community or share your knowledge.