几何尺寸与公差论坛

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

【转帖】plot, print to pdf and open up a word documen

[复制链接]
发表于 2009-4-13 13:31:07 | 显示全部楼层 |阅读模式
plot, print to pdf and open up a word document
hello,
i have made a macro.
it's printing my drawing and prints it to pdf, putting it in the same directory where the parts are located.
this works fine but,
is it possible that the macro also open up a ms word document?
thx.
sw 2008 sp 4.0
you may want to be a bit more specific. would you like your macro to literally just open a ms document and do nothing else, or print it, or something else..?
hello,
thx for the reply.
first of all i would like to open a ms word document, the macro that print and saves as pdf works already.
hope you get it
thx michel
sw 2008 sp 4.0
edited: 08/01/2008 at 03:17 am by michel opra
in that case you can just use the shell command to open the document by its default program (presumably ms word), for example:
shell "c:\myfile.doc", vbnormalfocus
ok thx, but i doesn't works, but this part (open a word documen) works already with a different command line
i have another question,
i would like to save the pdf as it's part name, let say 7021234.pdf but i would like to add the revision to it.
so it would be 7021234 revision a.pdf, and if you do a nother revision it turns to 7021234 revision b.pdf and so on.
hope you can help me with it.
sw 2008 sp 4.0
you need to read the custom property of the part using modeldoc2::extension::custompropertymanager, then using that custom property manager call
dim val1 as string
dim val2 as string
cpm.get2 "revision", val1, val2
and then val2 will have the revision value to use as you like
hello
thx, but i think that this part is to difficult for me.
maybe you can help me start. this is what i have for now.
where do i put the lines etc. ect.
thx
dim swapp as sldworks.sldworks
dim part as sldworks.modeldoc2
sub main()
set swapp = application.sldworks
set part = swapp.activedoc
dim filepath as string
dim pathsize as long
dim pathnoextension as string
dim newfilepath as string
filepath = part.getpathname
pathsize = strings.len(filepath)
pathnoextension = strings.left(filepath, pathsize - 6)
newfilepath = pathnoextension & "pdf"
modeldoc2:: extension:: custompropertymanager
part.saveas2 newfilepath, 0, true, false
set swapp = application.sldworks
set part = swapp.activedoc
set selmgr = part.selectionmanager
swapp.activedoc.activeview.framestate = 1
'part.printdirect
msgbox "saved as .pdf file and printed" & newpilepath
'open word drawing issue template
set appwd = createobject("word.application")
appwd.visible = true
appwd.documents.open filename:="r:\general office\templates\drawing-issue-note.docm"
end sub
sw 2008 sp 4.0
haven't testing anything but...
dim swapp as sldworks.sldworks
dim part as sldworks.modeldoc2
sub main()
set swapp = application.sldworks
set part = swapp.activedoc
dim filepath as string
dim pathsize as long
dim pathnoextension as string
dim newfilepath as string
dim valrev1 as string
dim valrev2 as string
filepath = part.getpathname
pathsize = strings.len(filepath)
pathnoextension = strings.left(filepath, pathsize - 7)
part.extension.custompropertymanager.get2 "revision", valrev1, valrev2
newfilepath = pathnoextension & "revision " & valrev2 & ".pdf"
part.saveas2 newfilepath, 0, true, false
set swapp = application.sldworks
set part = swapp.activedoc
set selmgr = part.selectionmanager
swapp.activedoc.activeview.framestate = 1
'part.printdirect
msgbox "saved as .pdf file and printed" & newpilepath
'open word drawing issue template
set appwd = createobject("word.application")
appwd.visible = true
appwd.documents.open filename:="r:\general office\templates\drawing-issue-note.docm"
end sub
msgbox "saved as .pdf file and printed" & newfilepath
be careful.
cad monkey
sw2k7 sp5.0
sw2k8 sp3.0
hello
thx dan hehehe wrong copy/past
at luke, thx for the quick reply's
but unfortunately,
sw 2008 sp 4.0
click for full image
sorry,
part.extension.custompropertymanager("").get2 "revision", valrev1, valrev2
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-23 08:56 , Processed in 0.036418 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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