几何尺寸与公差论坛

 找回密码
 注册
查看: 800|回复: 0

【转帖】macro to print to default printer

[复制链接]
发表于 2009-4-13 12:41:11 | 显示全部楼层 |阅读模式
macro to print to default printer
gotta problem.
we are remodeling our office and people are moving but the printers aren't. the problem is sw doesn't print to the default printer, it prints to whatever the drawing has for printer settings.
so, we have users across the buliding that are printing sw documents and then realize that the printer isn't next to them anymore.
so i was wondering if anyone has a macro that would print to the windows default printer?
rob jensen
southern mn solidworks user group leader
hello rob,
i believe what you are after is:
modeldoc2:: printdirect
description:
this method prints the current document to the default printer.
the macro you are after would be something in the lines:
option explicit
dim swapp as sldworks.sldworks
dim modeldoc as sldworks.modeldoc2
sub main()
set swapp = application.sldworks
set modeldoc = swapp.activedoc
modeldoc.printdirect
end sub
hope it helps
--stav.
p.s you can also use modedoc2:: printer to get or set the default printer.
in this world i am nobody...
and nobody is perfect ;) !!!
---------
solidworks office 2008 sp4.0
dell precision pws390
nvidia quadro fx 3450/4000 sdi
edited: 10/31/2007 at 05:27 am by stavros antoniou
hi, is there a way to write into the macro which printer to select? printdirect seems limited as you can't specify which sheets to print etc. we have a macro to print our drawings however would like the user running the macro to be able to specify which printer they use.
thanks, ben
hello ben,
yes there is.
have a look at
modeldoc2::printer.
description
this property gets or sets the default printer for this document.
once you set your default printer:
remarks
modeldoc2::printdirect and modeldocextension::printout2 use this setting if you pass an empty string to printer.
cheers,
--stav.
in this world i am nobody...
and nobody is perfect ;) !!!
---------
solidworks office 2008 sp4.0
dell precision pws390
nvidia quadro fx 3450/4000 sdi
edited: 12/20/2007 at 08:55 am by stavros antoniou
thanks stav,
i've worked out how to use the printout2 command, but was trying to see if there is a way to see what the printer names are that are available to print to. i basically want the person running the macro to be able to select which printer their drawings will get printed to, from a list of available printers on their computer.
is there any way to do this?
thanks, ben
for getting a list of printers, i've used enumerating printers api as describe by microsoft kb 200611. (
thanks michael,
yeah the main reason i'm needing to look into getting the list of printers is we have varying case for our printer names too.
for vb2005 i'm using this:
dim myprinter as string
cbprinter.items.clear()
for each myprinter in system.drawing.printing.printersettings.installedprinters
cbprinter.items.add(myprinter)
next
--john
quick
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-12-23 13:48 , Processed in 0.035731 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表