VBA SelectAll

T

td

In VBA how do you
1. select all text in a document?
2. Copy the selected text to the clipboard?
Thanks
td
 
H

Helmut Weber

Hi,
In VBA how do you
1. select all text in a document?
2. Copy the selected text to the clipboard?

without going into detail, try:

ActiveDocument.Range.Select
ActiveDocument.Range.Copy

whereby "ActiveDocument.Range.Select" is redundant.

And, that copies _everything_, not only text.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
T

td

Hello Helmut
When you say "Copies everything" does that include the FILE header & footer?
I am very happy to copy "everything" except these as they contain links to
non-existant files including templates. The object of the exercise is to get
rid of these non-existant links. Manual SelectAll, Copy and Paste into new
document does appear to solve the problem
Many thanks for your input
td
 
H

Helmut Weber

Hi td,

if you exclude the last paragraph mark,
which is what in former times was the end-of-doc mark,
and which carries a lot more of information
than an ordinary paragraph mark,
then you get nothing but the content of the main story.

Like, this time using selection:

Sub testcopy()
Selection.WholeStory
Selection.End = Selection.End - 1
Selection.Copy
End Sub

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
G

Grateful

re
ActiveDocument.Range.Select
ActiveDocument.Range.Copy

I want to thank you so much for this code. I had been looking for this
ability, to include Headers/Footers, etc. and only came up with answers that
it couldn't be done.

This is terrific. Thank you, Danke
 

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