Change the file name in the saved-under window - vba macro

Hello

I haven't found an answer to my problem while surfing the web, so I'm going for it:

I'm writing a macro to simplify the realization of my drawings. I'm coming to the end of writing my macro, but I still have only one last step that causes me problems: recording.

I manage to work the saved-under window with the following code:

[syntax=VB] Dim swApp As Object

Sub main()

Set swApp = _

Application.SldWorks

Set swModel = swApp.ActiveDoc

swModel.Extension.RunCommand swCommands_SaveAs, Empty

End Sub[/syntax]

 

But the thing is that this saved-under window offers me a filename that doesn't suit me. I would like to change the name of the file proposed by default according to a variable (RefMiseEnPlan) that retrieves the information located in the basemap previously entered. 

I managed to retrieve the information located in the basemap and store it in RefMiseEnPlan, but I couldn't find the code to change the default name offered in the saved-under dialog when it appears  :cry::mrgreen: 

Thank you in advance for your attention.


capture.jpg

Hello

You need to use the SaveAs3 method described here: http://help.solidworks.com/2016/english/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.IModelDoc2~Save3.html

An example here: http://help.solidworks.com/2016/english/api/sldworksapi/Save_File_Example_VB.htm

See you.

Rather this: http://help.solidworks.com/2016/english/api/sldworksapi/SOLIDWORKS.Interop.sldworks~SOLIDWORKS.Interop.sldworks.IModelDocExtension~SaveAs.html

Otherwise with Save As 3 which works (without registration window)

Dim longstatus as long

longstatus = swModel.SaveAs3("Full path + filename with extension", 0, 0)

Hello

See if it can help you.

http://www.lynkoa.com/tutos/import-export-formats-neutres/macro-solidworks-fenêtre-ouvrir

Hello 

In what you offer me the saved-under dialog window is no longer displayed, so I can no longer choose where I save my drawing. 

Re 

I answered too quickly, I hadn't seen all the answers.

For the method with SaveAs3, I don't like it too much because the l registered-under dialog window doesn't appear, but thanks

For the other solutions proposed, I will try to make them work and I will give you feedback

Thank you again.