Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access 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
 
Old December 4th, 2003, 05:41 AM
Registered User
 
Join Date: Dec 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Copying some part of the doc using macro in word

Hello,

i want to copy some part(means the content between two words namely "word1" AND "word2" in the document )of the word document and to place in other word document using a macro.

Can any body know the code for the macro.
 
Old December 4th, 2003, 04:04 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this code

Sub SelectRange()
Dim lCharpos1 As Long
Dim lCharpos2 As Long

    ActiveDocument.Bookmarks("\StartOfDoc").Select

    Selection.Find.Execute "word1"
    lCharpos1 = Selection.Range.Start
    Selection.Collapse

    Selection.Find.Execute "word2"


    lCharpos2 = Selection.Range.End

    ActiveDocument.Range(Start:=lCharpos1, End:=lCharpos2).Select
    Selection.Range.Copy

End Sub

v-m
 
Old December 5th, 2003, 05:36 AM
Registered User
 
Join Date: Dec 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks a lot.

it's working.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating word doc - word behaviour mat41 Classic ASP Professional 2 April 29th, 2007 06:46 PM
Copying part of a record FierceDeity Access 2 April 3rd, 2007 05:45 PM
Copy text from 1 doc to other doc thru vba in word itchock Word VBA 2 December 29th, 2006 02:47 AM
Word 2000 VBA AutoCorrect copying rjohnson VB How-To 0 August 30th, 2004 12:40 PM
Copy word to word doc. in VB vamshi Pro VB 6 1 March 24th, 2004 06:25 PM





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