Save As i.e. "Ln 1, Col 1-5"

D

David P.

I have used similiar code in Excel where you can save as cell "a1" for
example (meaning saving the document under the text in "a1"). In word can I
specify:

Save as the text in Ln 1, Columns 1-5 for example?

I would also want to add an "&" option i.e.

And Ln 2, Columns 1-5.

Is this out of the scope for Word?
 
A

Anand.V.V.N

I think it should be possible, this is just a long shot, just check if there
is a macro or something that is fired when the save or save as option is used
i.e. when the dialog box is displayed. You can extract the text from where
you want, and try to pass the that string to the filename field in of the
dislog box of word, sounds linke a good idea, but I am not sure if this is
the method to do it or its possible or not.
Anand
 
S

Steve Yandl

David,

I'm not certain what you mean by "Columns 1-5" so this might not be quite
what you had in mind. The short sub below is one example that would find
the first five characters in line 1 and the first 5 characters in line 2
plus the file extension ".doc" and do a SaveAs with that name.

Sub TestTwo()
Dim strLn1 As String
Dim strLn2 As String
Selection.GoTo What:=wdGoToLine, Which:=wdGoToAbsolute, Count:=1
strLn1 = Left(Selection.Bookmarks("\line").Range.Text, 5)
Selection.GoTo What:=wdGoToLine, Which:=wdGoToAbsolute, Count:=2
strLn2 = Left(Selection.Bookmarks("\line").Range.Text, 5)
ActiveDocument.SaveAs strLn1 & strLn2 & ".doc"
End Sub


Steve
 
D

David P.

Thank you. To Steve - what you suggested worked. I just had to make sure
there was no paragraph mark in the first five characters using your example.
 

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