Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-15-2018, 10:47 AM
klutch klutch is offline Pasting in word table, below bookmarks Windows 7 32bit Pasting in word table, below bookmarks Office 2016 for Mac
Advanced Beginner
Pasting in word table, below bookmarks
 
Join Date: Jun 2018
Posts: 31
klutch is on a distinguished road
Default Pasting in word table, below bookmarks

Hello, I am very close to completing a macro I've been working on for about two weeks. This is what I've aimed to accomplish:
1. Select a specific cell in excel correlating to specific text in column A (the length of my data rows will vary and I need to copy column E of the last row)
2. Select a word file from libraries (different files for each documentation)


3. Paste into word doc table in relating categories. (Pulling results for 3 different runs)

Here is my code
Code:
 Sub CopyAndPaste()
Dim myfile, wdApp As New Word.Application, wdDoc As Word.Document
myfile = Application.GetOpenFilename(, , "Browse for Document")
Dim i As Integer
i = Application.Match("Avg", Sheet1.Range("A1:A20"), 0)
Range("E" & i).Select
Selection.Copy
 
wdApp.Visible = True
Set wdDoc = wdApp.Documents.Open(myfile)
'select the word range you want to paste into
  If Range("c2") = 22 Then wdDoc.Bookmarks("d22").Select
  If Range("c2") = 5 Then wdDoc.Bookmarks("d5").Select
  If Range("c2") = -20 Then wdDoc.Bookmarks("d20").Select
 
 
 
    'and paste the clipboard contents
    wdApp.Selection.Paste
End Sub
This code accomplishes my first two objectives, and partially the third.
As you can see, I have used bookmarks to paste where I want to in the doc. However, this table will be updated every 18 months per review standard and the people using it have no VBA experience(they wont know how to change the bookmarks in code). This means that the text being pasted into the current bookmarks will be replaced with the new data. This is no good for what I want to accomplish with this macro.

is there a way to code so that if the bookmark already has text in it, the data will be pasted below it?

I know this is more of an excel problem but I have been told several times that my best luck finding an answer to this question would be in a word forum.

If anyone has anything to add to this I would be very appreciative!!
Reply With Quote
 

Tags
bookmark, if statement, vba

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pasting in word table, below bookmarks Pasting table data so that it will wrap around the table rebmaboss Word 1 11-25-2016 02:30 AM
Pasting text from Excel cell into word without creating a table, and keeping the in-cell formatting hanvyj Excel Programming 0 08-28-2015 01:15 AM
How to insert a table using bookmarks in a document Catty Word VBA 3 05-04-2015 03:05 AM
Pasting in word table, below bookmarks Table of Bookmarks Niy Word 3 03-28-2012 12:18 AM
Pasting table in Photoshop cutting off table azdolfan Word Tables 0 05-16-2010 01:52 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:15 AM.


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