Group: microsoft.public.word.vba.general
From: =?Utf-8?B?Smlt?=
Date: Sunday, February 24, 2008 11:56 AM
Subject: how to put default suggested filename in SaveAs FileName:?

I have the following simple macro to take a selection from a long document
and create a new document from it, the problem is that every time I use it,
the new file is saved to the same file name and over writes the old one. What
I would like is to have the file saved to the default suggested file name
that word would normally generate from the first line of the selection.
Anyone know what the variable for FileName should be to make this so?

Thanks Jim

Sub NewDocFromSelection()
'
' NewDocFromSelection Macro
' Create new document from selection
'
Selection.Copy
Documents.Add DocumentType:=wdNewBlankDocument
Selection.PasteAndFormat (wdPasteDefault)
ChangeFileOpenDirectory "D:\My websites\"
ActiveDocument.SaveAs FileName:="What causes this Syndrome.docx", _
FileFormat:=wdFormatXMLDocument, LockComments:=False, Password:="", _
AddToRecentFiles:=True, WritePassword:="",
ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False,
SaveFormsData _
:=False, SaveAsAOCELetter:=False
ActiveWindow.Close
End Sub

Safety Articles | Usenet Groups | Usenet News | Bluegrass