Anyone know how i copy out some text from word doc to another word doc using vba?
Printable View
Anyone know how i copy out some text from word doc to another word doc using vba?
Can you be more specific? Do you have any code so far?
You could use
VB Code:
Dim myDoc as object Dim strParagraph as string set myDoc = Documents.open (filename.doc) strParagraph = myDoc.paragraph(1) myDoc.close savechanges:=false activedocument.typetext strParagraph
to pull the first paragraph from filename.doc into the selected area of the current doc...
Hope this helps,
sugarflux
I would also like to know this! I would like to know the fastest way to copy all the text/tables from many documents into one master document. Is this possible with Get and Put? I don't mind saving the contents of these documents in binary with Put (if that is at all possible). At the moment i'm selecting all and copying it across :/
VB Code:
Documents.Open fileName:=CurrentDir + "Data\" & clauseDoc, ConfirmConversions:=False, _ ReadOnly:=True, AddToRecentFiles:=False, PasswordDocument:="", _ PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _ WritePasswordTemplate:="", Format:=wdOpenFormatAuto 'Activate clause file and copy the contents to the clipboard Documents(clauseDoc).Activate Selection.WholeStory Selection.Copy 'Activate This document and paste from the clipboard ThisDocument.Activate Selection.Paste