p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Word VBA (http://p2p.wrox.com/forumdisplay.php?f=231)
-   -   how to copy text in a word file on the clipboard (http://p2p.wrox.com/showthread.php?t=53398)

donrafeal January 30th, 2007 04:50 PM

how to copy text in a word file on the clipboard
 
I need to know how I can use VBA to select a word file and extract the body of that file to place it on the clipboard. The reason for this is I have an MS Access database which I am creating an automated email function with VBA. I want to use VBA to select a word file or word template with autotext and grab all the text within the body of the word file and place it in the body of the email...then with VBA send the email without user involvement. Does anyone have a code example for this? thanks in advanced.

donrafeal


Shasur January 31st, 2007 12:59 AM


Activedocument.Content.Copy

will copy the contents of the active (current) document.

you can use appropriate object like Documents(1) etc

Cheers
Shasur


http://www.vbadud.blogspot.com

donrafeal January 31st, 2007 11:22 AM

thanks for the help with that. Is there a way to copy the content of a file that is not open?


Shasur February 1st, 2007 12:32 AM

You can open the word document thru code and then close it

Set oWD = Word.documents.open("c:\sample.doc")

oWD.Content.Copy

' Do the pasting operations

oWD.close SaveChanges:=False

Hope this works out

If you do not want to open Word etc, I think, you can try out reading the file in binary more and transferring the contents

Cheers
Shasur


http://www.vbadud.blogspot.com


All times are GMT -4. The time now is 04:40 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.