|
dialog box sample code
can anyone share some sample code for calling the common saveas dialog box? the books i have don't really show enough detail for me to understand. when i recorded a macro, the code doesn't show how to call up the dialog box. do you have to declare any variables? how do i pass the filename to the actual saveas code? i'm looking at a macro that defaults to a dwg extension to save drawings to the shop floor and for customers who still want autocad files. thanks for your help.
mike closson - cswa
sw 2009 sp3.0 x64
intel xeon e5345 dual 2.33ghz + 4gb ram
nvidia quadro fx 1500
vista business x64 sp1
3dconnexion spacepilot
hi michael,
you can use the modeldocextension::saveas function call and by appending in the "name" string the .dwg extension you can save your drawing as dwg.
as for the name of the document to be saved you can use an inputbox and prompt the user to enter a name or you can get the name of the active drawing and reuse that.
have a look at the example available in the api help for the saveas function to see how to use it.
if you have issues with that or if its unclear reply here and we'll sort it out.
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
stav.,
thanks for the quick response. i already have code written that uses an inputbox and "grabs" the current path and defaults to the current filename using getpathname. this works just fine. but i would like to go one step further and use the common saveas dialog box. from what i've seen and read, it seems people shy away from using common dialog boxes. i'm guessing because of the extra code it would require versus the fairly simple code an inputbox uses to get the same basic results.
mike closson - cswa
sw 2009 sp3.0 x64
intel xeon e5345 dual 2.33ghz + 4gb ram
nvidia quadro fx 1500
vista business x64 sp1
3dconnexion spacepilot
i haven't been able to use the standard windows "save as" box with the vba that comes with solidworks. if you use vb6 or .net then you can use the dialog boxes.
dan miel
hi michael,
i am not sure how that is done in sw vba. i had a quick look in the net but with no luck.
sorry i could not help,
--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
add a form to your macro and add the microsoft commondialogcontrol to it. you'll need to add it to the controls toolbox by right-clicking and selecting additional controls. add the control to your form and then use something similar to this in your macro...
'--------------------
userform1.commondialog1.filter = "solidworks part (*.sldprt)|*.sldprt"
userform1.commondialog1.showsave
debug.print userform1.commondialog1.filename
'---------------------
you don't ever need to show the form to the user, but the common dialog control works in the context of a form. in .net you can do it without the form.
there are many other customizations you can make to the common dialog control to customize its behavior. check out its (custom) property for more.
mike spens
"automating solidworks using macros"
leap frog leap pad x64
i have tried that in vba here at work, but i get a message that says "the control could not be created because it is not properly licensed." it does seem that at one time when i was home, where i have vb6 installed on my machine, the dialog box could be put in the macro.
mike spens,
i have your book on automating sw 06. it was helpful in what i've done so far with this and other macros but you don't really touch on the subject of cdb's. just for another newbie challenge, i may try to create my own form.
mike closson - cswa
sw 2009 sp3.0 x64
intel xeon e5345 dual 2.33ghz + 4gb ram
nvidia quadro fx 1500
vista business x64 sp1
3dconnexion spacepilot
could be related to problems posted in this ms knowledgebase article.
support.microsoft.com/kb/177799/en-us/
mike spens
"automating solidworks using macros"
leap frog leap pad x64
quick |
|