几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » SolidWorks二次开发
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-04-13, 12:31 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】list all network printers

list all network printers
i used this loop to list all network printes
dim x as printer
for each x in printers
cboprinters.additem x.devicename
next
but it doesn't seem working.
any idea?
thx, chris
solidworks 2007 (office pro.) sp5.0
testing solidworks 2009 (pro) sp0.0
dell precision t3400
2 cpu (8500) 3.16 ghz, 3.25 gb of ram
window xp pro sp2
nvidia fx 570 6.14.11.6262
chris,
what's the error? if you add a watch on the printers object, do you see your printers?
i have used the for each x in printer method and also enumprinters (search msdn for enumprinters). both work fine for me, but enumprinters method takes more code.
mike
i got the error: user-defined type not defined
see the att. image for ref
thx, chris
solidworks 2007 (office pro.) sp5.0
testing solidworks 2009 (pro) sp0.0
dell precision t3400
2 cpu (8500) 3.16 ghz, 3.25 gb of ram
window xp pro sp2
nvidia fx 570 6.14.11.6262
ok, you are right to look under references. i used visual basic 6.0 with the printers object. with some digging, the reference it needs is "visual basic objects and procedures" (vb6.olb). this is not a listed reference in solidworks vba. that did not stop me though and i used the browse button to manually select vb6.olb. the dim statement then reconized the object, but when it got to the for each x in printer statement, it crashed solidworks.
so the bottom line is, it does not look like you can use the printers object in solidworks vba. vb6 works great with printer object though, so if you have it, that's the way to go. if you don't have vb6, i would suggest trying the enumprinters method. it's a bit involved, but it does work inside solidworks vba.
-mb
i do have vb6
how to load it into the sw vba?
thx, chris
solidworks 2007 (office pro.) sp5.0
testing solidworks 2009 (pro) sp0.0
dell precision t3400
2 cpu (8500) 3.16 ghz, 3.25 gb of ram
window xp pro sp2
nvidia fx 570 6.14.11.6262
paste the following code into a new vb6 project and set your references as shown in the attachment. i'm not sure what you are asking about "load it into the sw vba", but the last couple lines in this example gets the solidworks object and the modeldoc object from vb6.
-mb
private sub main()
dim x as printer
dim swapp as sldworks.sldworks
dim swmodeldoc as modeldoc2
'printers
for each x in printers
if x.devicename = "pdf995" then
set printer = x
printer.papersize = 158
exit for
end if
next
'linking to solidworks
set swapp = createobject("sldworks.application")
set swmodeldoc = swapp.activedoc
end sub
click for full image
michael,
i never have problem with vb6 - so this code works fine
dim x as printer
for each x in printers
cboprinters.additem x.devicename
next
however, when i add them to solidworks vba, i got an error
thx, chris
solidworks 2007 (office pro.) sp5.0
testing solidworks 2009 (pro) sp0.0
dell precision t3400
2 cpu (8500) 3.16 ghz, 3.25 gb of ram
window xp pro sp2
nvidia fx 570 6.14.11.6262
chris,
as far as i can tell it does not look like you can use the "printers" object in solidworks vba. (in a prior post i said i had attempted to add the vb6 reference (vb6.olb) to solidworks vba, but it crashes solidworks). i would suggest using the enumprinters method.
-mike
quick
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】an unknown network error occurred. 9400 yang686526 SolidWorks二次开发 0 2009-04-13 08:51 AM
【转帖】solidworks developer network yang686526 SolidWorks二次开发 0 2009-04-12 10:28 PM


所有的时间均为北京时间。 现在的时间是 06:14 PM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多