Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-16-2018, 12:37 AM
Jovan Yong Jovan Yong is offline Macro to transfer data from Word to another Word document with bookmark Windows 10 Macro to transfer data from Word to another Word document with bookmark Office 2016
Novice
Macro to transfer data from Word to another Word document with bookmark
 
Join Date: Apr 2018
Posts: 5
Jovan Yong is on a distinguished road
Default Macro to transfer data from Word to another Word document with bookmark

Hi guys , i have a word document with a list of data, and i want transfer all the data into another word document that i bookmark to replace it.
What should i put under the Selection.TypeText?

Application.Documents.Open ("C:\Users\jovany\Desktop\NEW WOSPC 9.2.1_RMIR - Rollout.doc")
Selection.GoTo What:=wdGoToBookmark, Name:="Bookmark"


ThisDocument.Activate
Selection.TypeText Text:=""
Reply With Quote
  #2  
Old 04-16-2018, 01:20 AM
gmayor's Avatar
gmayor gmayor is offline Macro to transfer data from Word to another Word document with bookmark Windows 10 Macro to transfer data from Word to another Word document with bookmark Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Something seems to have been lost in the explanation. However you seem to have a document with a macro (ThisDocument) and another document with a Bookmarked text and you want to copy that bookmarked text to the document with the macro? That being the case

Code:
Dim oDoc As Document
Dim oTarget As Document
Dim oBM As Range
Dim oRng As Range
    Set oTarget = ThisDocument
    Set oRng = oTarget.Range
    oRng.Collapse 0
    Set oDoc = Documents.Open("C:\Users\jovany\Desktop\NEW WOSPC 9.2.1_RMIR - Rollout.doc")
    Set oBM = oDoc.Bookmarks("bookmark").Range
    oRng.FormattedText = oBM.FormattedText
    oRng.Bookmarks.Add "bookmark2"
    oTarget.Activate
    Set oDoc = Nothing
    Set oTarget = Nothing
    Set oRng = Nothing
    Set oBM = Nothing
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 04-16-2018, 02:00 AM
Jovan Yong Jovan Yong is offline Macro to transfer data from Word to another Word document with bookmark Windows 10 Macro to transfer data from Word to another Word document with bookmark Office 2016
Novice
Macro to transfer data from Word to another Word document with bookmark
 
Join Date: Apr 2018
Posts: 5
Jovan Yong is on a distinguished road
Default

Sorry for my bad english,
I want to transfer my non bookmarked data from 1 word document to the bookmarked word document
Reply With Quote
  #4  
Old 04-17-2018, 04:27 AM
gmayor's Avatar
gmayor gmayor is offline Macro to transfer data from Word to another Word document with bookmark Windows 10 Macro to transfer data from Word to another Word document with bookmark Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

It is just a matter of swapping the documents and their ranges around so that you copy one range to the other e.g.

Code:
Dim oDoc As Document
Dim oTarget As Document
Dim oBM As Range
Dim oRng As Range
    Set oTarget = ThisDocument
    Set oBM = oTarget.Bookmarks("bookmark").Range
    Set oDoc = Documents.Open("C:\Users\jovany\Desktop\NEW WOSPC 9.2.1_RMIR - Rollout.doc")
    Set oRng = oDoc.Range
    oBM.FormattedText = oRng.FormattedText
    oBM.Bookmarks.Add "bookmark"
    oTarget.Activate
    oDoc.Close 0
    Set oDoc = Nothing
    Set oTarget = Nothing
    Set oRng = Nothing
    Set oBM = Nothing
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply

Tags
vba macro

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to transfer data from Word to another Word document with bookmark split word document based on bookmarks with each new document title of the bookmark megatronixs Word VBA 9 09-05-2020 02:29 PM
Transfer data from list with multiple headings from word to excel psohms Word 1 06-11-2015 04:39 PM
Macro to transfer data from Word to another Word document with bookmark Transfer word doc bookmarks to excel using macro Bedsy Word VBA 4 03-15-2015 10:58 PM
Transfer Data between Excel and Word s_samira_21 Excel 0 01-19-2015 05:21 AM
Data transfer from Word tables to Excel shoro Word 4 10-01-2013 05:08 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:36 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft