Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Other Office > Word VBA
| Search | Today's Posts | Mark Forums Read
Word VBA Discuss using VBA to program Word.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Word VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old January 30th, 2007, 04:50 PM
Authorized User
 
Join Date: Apr 2004
Location: , , .
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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

  #2 (permalink)  
Old January 31st, 2007, 12:59 AM
Friend of Wrox
Points: 3,060, Level: 23
Points: 3,060, Level: 23 Points: 3,060, Level: 23 Points: 3,060, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: , , .
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default


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
  #3 (permalink)  
Old January 31st, 2007, 11:22 AM
Authorized User
 
Join Date: Apr 2004
Location: , , .
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

  #4 (permalink)  
Old February 1st, 2007, 12:32 AM
Friend of Wrox
Points: 3,060, Level: 23
Points: 3,060, Level: 23 Points: 3,060, Level: 23 Points: 3,060, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: , , .
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Drop Changes or Copy to clipboard JezLisle Access VBA 4 November 20th, 2008 10:24 AM
Copy Metafile to the Clipboard TMA_Master BOOK: Visual Basic 2008 Programmer's Reference ISBN: 978-0-470-18262-8 1 August 26th, 2008 10:59 PM
Copy text to win Clipboard irresistible007 Beginning VB 6 6 October 5th, 2006 06:04 AM
Copy to Clipboard Clive Astley Access 5 July 16th, 2004 07:16 PM
convert Word file to jpg w/o using clipboard lam_bon_bon VB How-To 0 September 13th, 2003 05:27 AM





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