load userform the moment the Save as dialog screen closes

E

Edwin Verwer

is it possible the determine if the Save as dialog screen is active or not.
And is it also possible to to load a other screen (userform) the moment the
Save as dialog screen closes.
 
J

Jay Freedman

Edwin said:
is it possible the determine if the Save as dialog screen is active
or not. And is it also possible to to load a other screen (userform)
the moment the Save as dialog screen closes.

There is no way to determine whether any built-in dialog is open unless your
code was responsible for showing it.

You'll have to intercept the Save As command with your own macro (named
FileSaveAs in order to catch the command) and make it behave as you want:

Sub FileSaveAs()
Dim myUF As UserForm1
Set myUF = New UserForm1
If Dialogs(wdDialogFileSaveAs).Show = -1 Then
' user click OK in the dialog
myUF.Show
End If
Set myUF = Nothing
End Sub

To catch the Save As dialog that displays when the user first saves a new
document, you also need a FileSave macro:

Sub FileSave()
Dim myUF As UserForm1
Set myUF = New UserForm1
If Len(ActiveDocument.Path) = 0 Then
If Dialogs(wdDialogFileSaveAs).Show = -1 Then
' user click OK in the dialog
myUF.Show
End If
Else
ActiveDocument.Save
End If
Set myUF = Nothing
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
A

Art H

There is no way to determine whether any built-in dialog is open unless your
code was responsible for showing it.

You'll have to intercept the Save As command with your own macro (named
FileSaveAs in order to catch the command) and make it behave as you want:

Sub FileSaveAs()
    Dim myUF As UserForm1
    Set myUF = New UserForm1
    If Dialogs(wdDialogFileSaveAs).Show = -1 Then
        ' user click OK in the dialog
        myUF.Show
    End If
    Set myUF = Nothing
End Sub

To catch the Save As dialog that displays when the user first saves a new
document, you also need a FileSave macro:

Sub FileSave()
    Dim myUF As UserForm1
    Set myUF = New UserForm1
    If Len(ActiveDocument.Path) = 0 Then
        If Dialogs(wdDialogFileSaveAs).Show = -1 Then
            ' user click OK in the dialog
            myUF.Show
        End If
    Else
        ActiveDocument.Save
    End If
    Set myUF = Nothing
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ:http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroupso
all may benefit.

Maybe using the DocumentBeforeSave Event to start the OnTime method
could get you there? See VBA help for more details.
 
J

Jay Freedman

Art said:
Maybe using the DocumentBeforeSave Event to start the OnTime method
could get you there? See VBA help for more details.

I don't think that's going to work. What interval would you give the OnTime
method? You have no idea how long the Save As dialog will sit open while the
user ignores it or trawls through various folders, so you still don't know
when to display the userform.
 

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