From: Jon R. Odden Jon R. on
What is the CANCEL_PRESSED?

I try this in Office 2007 and get a Compile error: Variable not defined. And
of course - this is correct. So how can this work?


Regards,
Jon


"Doug Robbins - Word MVP" wrote:

> Use:
>
> Dim fd As FileDialog
>
> Set fd = Application.FileDialog(msoFileDialogSaveAs)
> With fd
> .InitialFileName = "FirstName_LastName"
> If .Show = CANCEL_PRESSED Then
> Else
> .Execute
> End If
> End With
> Set fd = Nothing
>
>
> --
> Hope this helps
>
> Doug Robbins - Word MVP
> Please reply only to the newsgroups unless you wish to avail yourself of my
> services on a paid, professional basis.
>
> "Sally Green" <SallyGreen(a)discussions.microsoft.com> wrote in message
> news:0D18D75C-EE36-4E61-97B9-F0D954E7EEFD(a)microsoft.com...
> > Using vba code and Word 2003, I need to be able to suggest a file name in
> > the
> > Save As dialog using underscores to separate words, eg My_filename.doc
> >
> > I have tried all manner of things to do this and have partially succeeded
> > using:
> > ActiveDocument.SaveAs "My_filename"
> >
> > However, I need the Save As dialog to show so that the user can select the
> > relevant folder. As this folder can change from user to user I can't
> > default
> > the path into the code. I need a NoPrompt argument like the Save Method.
> > I've also used:
> > ActiveDocument.BuiltInProperties(wdPropertyTitle)="My_filename" but that
> > then suggest My.doc as the filename, everything after the underscore is
> > dropped out.
> > I've also tried the WordBasic.SetDocumentProperty "Title",0, "My_Filename"
> > - same problem.
> > And Documents.Save NoPrompt:=False with the same frustrating result.
> >
> > I found a useful article in
> > http://word.mvps.org/faqs/macrosvba/SetDefFilenameContent.htm
> >
> > The work around worked really well, it placed my very long filename with
> > appropriately placed underscores into the Title Property and the .show on
> > the
> > wdDialogFileSummaryInfo showed the title. However, when my code gets to
> > the:
> >
> > Dialogs(wdDialogFileSaveAs).Show
> >
> > the Save As dialog box is displayed but the suggested filename does not
> > pick
> > up the full name from the Document Properties - Title. Everything after
> > the
> > underscore is dropped out.
> >
> > Is there a known fix for this.
> >
> > My request in brief is to be able to display the Save As dialog with a
> > suggested name that includes underscores.
> >
> > Any help on this would be appreciated.
> >
> > Thanks
> > SG
> >
> >
> > I posted this once, but it hasn't appeared in the posted list. Apologies
> > if
> > it appears twice.
>
>
> .
>
From: Doug Robbins - Word MVP on
It does not produce an error here. However you can also use:

Dim fd As FileDialog

Set fd = Application.FileDialog(msoFileDialogSaveAs)
With fd
.InitialFileName = "FirstName_LastName"
If .Show = 0 Then 'user pressed the cancel button
Else
.Execute
End If
End With
Set fd = Nothing
End Sub


--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.

"Jon R. Odden" <Jon R. Odden(a)discussions.microsoft.com> wrote in message
news:90DB4DA4-0123-415F-B815-37F1C8197E24(a)microsoft.com...
> What is the CANCEL_PRESSED?
>
> I try this in Office 2007 and get a Compile error: Variable not defined.
> And
> of course - this is correct. So how can this work?
>
>
> Regards,
> Jon
>
>
> "Doug Robbins - Word MVP" wrote:
>
>> Use:
>>
>> Dim fd As FileDialog
>>
>> Set fd = Application.FileDialog(msoFileDialogSaveAs)
>> With fd
>> .InitialFileName = "FirstName_LastName"
>> If .Show = CANCEL_PRESSED Then
>> Else
>> .Execute
>> End If
>> End With
>> Set fd = Nothing
>>
>>
>> --
>> Hope this helps
>>
>> Doug Robbins - Word MVP
>> Please reply only to the newsgroups unless you wish to avail yourself of
>> my
>> services on a paid, professional basis.
>>
>> "Sally Green" <SallyGreen(a)discussions.microsoft.com> wrote in message
>> news:0D18D75C-EE36-4E61-97B9-F0D954E7EEFD(a)microsoft.com...
>> > Using vba code and Word 2003, I need to be able to suggest a file name
>> > in
>> > the
>> > Save As dialog using underscores to separate words, eg My_filename.doc
>> >
>> > I have tried all manner of things to do this and have partially
>> > succeeded
>> > using:
>> > ActiveDocument.SaveAs "My_filename"
>> >
>> > However, I need the Save As dialog to show so that the user can select
>> > the
>> > relevant folder. As this folder can change from user to user I can't
>> > default
>> > the path into the code. I need a NoPrompt argument like the Save
>> > Method.
>> > I've also used:
>> > ActiveDocument.BuiltInProperties(wdPropertyTitle)="My_filename" but
>> > that
>> > then suggest My.doc as the filename, everything after the underscore is
>> > dropped out.
>> > I've also tried the WordBasic.SetDocumentProperty "Title",0,
>> > "My_Filename"
>> > - same problem.
>> > And Documents.Save NoPrompt:=False with the same frustrating result.
>> >
>> > I found a useful article in
>> > http://word.mvps.org/faqs/macrosvba/SetDefFilenameContent.htm
>> >
>> > The work around worked really well, it placed my very long filename
>> > with
>> > appropriately placed underscores into the Title Property and the .show
>> > on
>> > the
>> > wdDialogFileSummaryInfo showed the title. However, when my code gets
>> > to
>> > the:
>> >
>> > Dialogs(wdDialogFileSaveAs).Show
>> >
>> > the Save As dialog box is displayed but the suggested filename does not
>> > pick
>> > up the full name from the Document Properties - Title. Everything after
>> > the
>> > underscore is dropped out.
>> >
>> > Is there a known fix for this.
>> >
>> > My request in brief is to be able to display the Save As dialog with a
>> > suggested name that includes underscores.
>> >
>> > Any help on this would be appreciated.
>> >
>> > Thanks
>> > SG
>> >
>> >
>> > I posted this once, but it hasn't appeared in the posted list.
>> > Apologies
>> > if
>> > it appears twice.
>>
>>
>> .
>>