How to call Save as dialog?

Valued Contributor
Valued Contributor

 

Hi All!

How to call "Save as..." dialog in VB code? I need to call "Save as..." dialog during run my macro, and I want to paste new filename (As String) in the "file name" field.

I don't want use SaveAs method, becouse user must select path himself in "Save as" dialog.

Is it possible?

 

Posted by: Anton Bykov
Post date: 6/30/2010 1:30:34 AM

7 REPLIES

RE: How to call Save as dialog?

Valued Contributor
Valued Contributor

for active File you can use:

objApp.GetSaveAsFileName(ByRef LinkSaveOption As Integer, ByRef SelectedFilter As Integer, Optional ByVal InitialFilename As Object = Nothing, Optional ByVal FileFilter As Object = Nothing, Optional ByVal FilterIndex As Object = Nothing, Optional ByVal Title As Object = Nothing, Optional ByVal IsTemplate As Object = Nothing) As Object

 

or:

 

objapp.StartCommand(57604)

 

 

Posted by: JR
Post date: 7/5/2010 11:21:54 PM

RE: How to call Save as dialog?

Valued Contributor
Valued Contributor

 

JR,

I use:

Call objApp.GetSaveAsFileName(lnkSO, SelFil, NewFileName, "Part (*.par),*.par")

Then "SaveAs" dialog is opens, I click the "Save" button, "SaveAs" dialog is closes and... nothing happens , part document doesn't save.

I don't want use "objApp.StartCommand (57604)", because I need NewFileName (As String) in File Name field.

Why objApp.GetSaveAsFileName(...) doesn't work?

 

Posted by: Anton Bykov
Post date: 7/6/2010 12:27:15 AM

RE: How to call Save as dialog?

Valued Contributor
Valued Contributor

The GetSaveAsFileName ist only the dialog to save.

You must call the SaveAs(...) method after.

Like this:

 

Dim sFileName as Object

sFileName =objApp.GetSaveAsFileName(lnkSO, SelFil, NewFileName, "Part (*.par),*.par")

If TypeOf sFileName Is String Then 'if cancel the type is boolean with false

objDoc.SaveAs(sFileName)

End If

 

Posted by: JR
Post date: 7/6/2010 8:49:58 PM

RE: How to call Save as dialog?

Valued Contributor
Valued Contributor

JR,

Are you sure, what "If TypeOf sFileName Is String Then" is correctly? Maybe not "String", becouse Micrisift Visual Basic shows "Compile error: Expected: Object or type name"

 

Posted by: Anton Bykov
Post date: 7/7/2010 8:52:27 PM

RE: How to call Save as dialog?

Valued Contributor
Valued Contributor

 

I try next code, and it worked:

Dim sFileName As String

        sFileName = objApp.GetSaveAsFileName(lnkSO, SelFil, NewFileName, "Part (*.par),*.par")

            If Not sFileName = False Then

            objDoc.SaveAs (sFileName)

            End If

Thank you!

 

Posted by: Anton Bykov
Post date: 7/7/2010 9:45:14 PM

RE: How to call Save as dialog?

Valued Contributor
Valued Contributor

Hi Frantic,

 

the method TypeOf is in vb6 only for objects and not for type string. In Visual Basic 2005 for all types.

I use VS2005/2010. Are you work with vb6?

 

 

Posted by: JR
Post date: 7/7/2010 10:52:58 PM

RE: How to call Save as dialog?

Valued Contributor
Valued Contributor

Hi, yes, I work with VB6

 

Posted by: Anton Bykov
Post date: 7/7/2010 11:29:59 PM