Save.. As Dialog

S

Steve Macleod

Hi, I am using:

Dialogs(wdDialogFileSaveAs).Show

To show a save..as dialog. I was wondering if someone could help in the
use of this.

How do I filter the dialog so that it defaults to .txt, and the c:\
directory?
Is there any way to trap the "cancel" action on the dialog?
How do I ensure that a user recieved notification that the file already
exists when attempting a file overright?

Many Thanks.
 
J

Jean-Guy Marcil

Steve Macleod was telling us:
Steve Macleod nous racontait que :
Hi, I am using:

Dialogs(wdDialogFileSaveAs).Show

To show a save..as dialog. I was wondering if someone could help in
the use of this.

How do I filter the dialog so that it defaults to .txt, and the c:\
directory?

See below.
Is there any way to trap the "cancel" action on the dialog?

Yes, see below.
How do I ensure that a user recieved notification that the file
already exists when attempting a file overright?

If users try to overwrite existing files, Word will warned them
automatically, you do not have to do anything special.

Try this:

'_______________________________________
Dim myDlg As Dialog
'To save and reset the user save format
Dim userFormat As Long

Set myDlg = Dialogs(wdDialogFileSaveAs)
userFormat = ActiveDocument.SaveFormat

With myDlg
.Name = "C:\"
.Format = wdFormatText '2
Select Case .Show
Case 0
MsgBox "User clicked on 'Cancel'."
Case -1
MsgBox "User clicked on 'Save'."
End Select
'Reset user format
.Format = userFormat
.Update
End With
'_______________________________________

I included some code to reset user settings.... It is good practice to
always leave things as you find them...

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
S

Steve Macleod

Just another thing actually :) ..
Im using .name to get the file name. How do I get the full file path
name? (to use to create the text file)

Thanks again
 
S

Steve Macleod

Sorry! yet another thing! (I am pestering now)
Is there any way to se the extension of the file to "save as" as ".sql"
as I am writing a macro to generate a database build script from a word
document.

Once again Thanks!!!
 
D

Doug Robbins - Word MVP

To get the path, use FullName.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
J

Jean-Guy Marcil

Steve Macleod was telling us:
Steve Macleod nous racontait que :
Sorry! yet another thing! (I am pestering now)
Is there any way to se the extension of the file to "save as" as
".sql" as I am writing a macro to generate a database build script
from a word document.

Once again Thanks!!!

Not that I know of.

sql is not one of the Word save filters.
If you save as .txt, and then write
mydoc.sql
Word will save it as
mydoc.sql

But, in the macro I am not sure you can achieve that.

If you try:

With myDlg
.Name = "C:\mydoc.sql"
.Format = wdFormatText '2

When the dialog is displayed, you get

"C:\mydoc.txt"

There maybe a trick to force to
"C:\mydoc.sql"
even if the save format is wdFormatText , but I do not know what it is as I
never had to do something like this.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
R

Russ

Steve,
You could force the saveas as "mydoc.txt" using .txt filter in SaveAs Dialog
to strip it of formatting by the method below in previous messages, then
maybe after a short pause for disk writing, use the Name statement (not the
..name Property) in VBA code to rename the file with a .sql extension to have
it recognized as a database file.

Read about the Name statement in the VBA help.
 

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