PDA

View Full Version : Grab contents of word document and put into a var ?



TheStalker
08-13-2010, 01:57 AM
Hi all,

I'm prewtty new to VBA.

What i'm looking to do it grab the contents of the word document(will only be a few lines) and put that into a document so i can place it else where later.

I've been on the MSDN and have been reading about the .selection but everytime i try and work it out i get errors :S

What would be the best/simplist way to go about this? I'm sure it can't be too hard for somone in the know.

Thanks for taking the time to read :)

Aussiebear
08-13-2010, 03:57 AM
As in cut & paste?

TheStalker
08-13-2010, 04:17 AM
thanks for your reply,

I want to be able to insert it into a form in IE later. I know how to put text into a form in ie i just need to be able to grab the text inside my word document first and store it so i can inster it later.

TheStalker
08-13-2010, 05:57 AM
i tried this
sText = selection.Text

but get an error "run time error 424" ?

Aussiebear
08-17-2010, 10:47 PM
Sorry for the delay. A couple of things firstly so we can understand better where you are coming from.

Can you tell us the name of the document to which you want to save the selected section of text in?

How do you envisage then reselecting the copied text?

How did you intend to save the copied text within the new document?

How do you intend to select the text and what triggers the code to save to new document?

fumei
08-18-2010, 12:34 AM
variable=ActiveDocument.Content