Save Dialog Box

87 views
Skip to first unread message

Chris Angevine

unread,
Aug 12, 2009, 9:31:34 AM8/12/09
to SolidWo...@googlegroups.com

            I’m seriously stuck and could use some help.  I’m trying to write a macro that will save the active drawing as a PDF.  No big deal.  I also want the user to be able to decide what directory they want to put it in and possibly change the name.  The next time the macro is run, I want to use the previous directory location as the starting directory.

            I originally did it by having the user type in the directory path.  It worked, but was cumbersome and prone to mistakes.  I want to use the Windows ‘GetSaveFileName’ dialog box as the interface.  Everyone is used to it.

            I was able to get the dialog box to come up and have the correct file name shown in it.  The problem is getting the location where the user saved it back from the dialog function.  It is supposed to return the path and file name with the “.lpstrFile” variable.  The problem is that it truncates the return.  If I run the macro over and over, it also becomes unstable. I don’t really understand VB, so I’m hoping that I’m missing something simple.  I just need that returned value and I can finish the rest of it.

            Has anyone had any success doing this?  Thanks.

 

Chris

           

SaveAsPDF.swp

Corey Scheich

unread,
Aug 16, 2009, 12:03:27 AM8/16/09
to solidwo...@googlegroups.com
Chris

If you are using 2009 or later you can write the macro in .NET VSTA (Visual Studio Tools for Applications) instead.  .Net has simple access to the SaveFileDialog object.  You can specify the initial folder and the default extension and retrieve the filename the user entered.  You will have to add a reference to System.Windows.Forms.dll and help for the dialog is found here http://msdn.microsoft.com/en-us/library/system.windows.forms.savefiledialog.aspx

Regards,

Corey Scheich


From: CAng...@calvauto.com
To: SolidWo...@googlegroups.com
Date: Wed, 12 Aug 2009 09:31:34 -0400
Subject: Save Dialog Box


Get free photo software from Windows Live Click here.

Engineer

unread,
Aug 16, 2009, 8:43:44 PM8/16/09
to SolidWorks-API
Check this "SaveAsPDF with Folder Selection" macro by Matt (http://
sw.fcsuper.com/index.php?name=UpDownload&req=getit&lid=130)

Deepak Gupta
SW2009 SP3.0
SW2007 SP5.0
http://gupta9665.wordpress.com/

On Aug 16, 9:03 am, Corey Scheich <cdsmor...@hotmail.com> wrote:
> Chris
> If you are using 2009 or later you can write the macro in .NET VSTA (Visual Studio Tools for Applications) instead.  .Net has simple access to the SaveFileDialog object.  You can specify the initial folder and the default extension and retrieve the filename the user entered.  You will have to add a reference to System.Windows.Forms.dll and help for the dialog is found herehttp://msdn.microsoft.com/en-us/library/system.windows.forms.savefile...
> Regards,
> Corey Scheich
> _________________________________________________________________
> Get free photo software from Windows Livehttp://www.windowslive.com/online/photos?ocid=PID23393::T:WLMTAGL:ON:...

Chris

unread,
Aug 17, 2009, 8:38:44 AM8/17/09
to SolidWorks-API
Corey,
Thanks. I will look into that option.

Chris

On Aug 16, 12:03 am, Corey Scheich <cdsmor...@hotmail.com> wrote:
> Chris
Reply all
Reply to author
Forward
0 new messages