Simple one for you old timers... SaveAs problem...

D

Domestos

Hi all,

I assume what i need to do is very simple, but i have not got a clue how to
do it. I have tried various things with no luck...

What I need to do is this...

I have a 120 page document, I need to copy each page in turn and paste it
into a new document. This I have managed to do...

I then need to save that new document with a dynamic filename. The filename
will be taken from the first word of the document. I have tried the
following but keep getting an error (expected function or variable)

Please help, and many thanks in advance...

eg.

Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend ' selects
first word in document
Selection.Copy ' copies selection
myDocname = Selection.Paste ' trying to paste my selection into a
variable
myDocname = myDocname & ".doc" ' appends '.doc' to variable
ActiveDocument.SaveAs FileName:=myDocname, FileFormat:= _
wdFormatDocument, LockComments:=False, Password:="",
AddToRecentFiles:= _
True, WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
ActiveWindow.Close


Domestos
 
J

Jonathan West

Hi Domestos

Try this

myDocName = ActiveDocument.Words(1).Text
ActiveDocument.SaveAs FileName:=myDocname
 
J

Jean-Guy Marcil

HI Domestos,

You just got 3 replies in the vba.general NG.

Please, do not multipost... it wastes everybody's time.

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

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