SaveAs dialog

A

Andy

I would like to popup a SaveAs dialog so that I can allow the user to
save a copy of my diagram, but I would like to specify/generate a
likely the filename. I can't use the DoCmd to popup the saveAs dialog
as I cannot specify the initial filename. If i try to change the name,
path and fullname I get an error as these are readonly. I was hoping
not to have to implement the dialog myself. If I do a similair thing in
VBA from Excel I am able to make use of the Excel dialogs.

Is it possible for me to use the Visio file dialogs?

Thanks
 
J

JuneTheSecond

Excel dialog msoFileDialogFilePicker would be a candidate.
A sample code is
Dim fd As FileDialog
Dim x As New Excel.Application
Dim vrtSelectedItem As Variant
x.Visible = False
Set fd = x.FileDialog(msoFileDialogFilePicker)
fd.Filters.Add "Visio Drawing", "*.vsd", 1
fd.AllowMultiSelect = False
If fd.Show = -1 Then
vrtSelectedItem = fd.SelectedItems(1)
Debug.Print "Path : " & vrtSelectedItem
ActiveDocument.SaveAsEx vrtSelectedItem, visSaveAsWS
End If
x.Quit
 
J

JuneTheSecond

Another idea may be to use msoFileDialogFolderPicker.
In this case, the code may become a bit long, and another userform may be
needed to enter or select file name. My test code is as follows.

Sub test()
Dim fd As office.FileDialog
Dim x As New Excel.Application
Dim strSelectedItem As String
x.Visible = False

Set fd = x.FileDialog(msoFileDialogFolderPicker)
fd.AllowMultiSelect = False
If fd.Show = -1 Then
strSelectedItem = fd.SelectedItems(1)
x.Quit

Debug.Print "Path : " & strSelectedItem
UserForm1.Show vbModeless
UserForm1.myPath = strSelectedItem
End If
End Sub

And for userform1,

Private strMyPath

Private Sub CommandButton1_Click()
Dim fs
Dim strFullName As String

Set fs = CreateObject("Scripting.FileSystemObject")
strFullName = strMyPath & "\" & Me.TextBox1.Text & ".vsd"
MsgBox strFullName
If fs.FileExists(strFullName) Then
If MsgBox("Same name already exists. Do you save?", vbYesNo +
vbQuestion) = vbYes Then
ActiveDocument.SaveAsEx strFullName, visSaveAsWS
End If
Else
ActiveDocument.SaveAsEx strFullName, visSaveAsWS
End If
Unload Me
End Sub

Public Property Let myPath(ByVal vNewValue As String)
strMyPath = vNewValue
End Property
 
A

Andy

Thanks for the suggestions. However, FileDialog is not available to me,
although I have Visio 2003, for the rest of Office I am stuck with
Office 97.
 
J

JuneTheSecond

If you have VB6, you can assemble a form like an old style filedialog.
The lattest VB .Net is said to have pretty file dialogs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top