![]() |
|
|
|
#1
|
|||
|
|||
|
I edited the last block of code I posted. I think it should be ok now.
Basically, if you go back to the original code you posted, rather than using ... Code:
wdApp.Selection.Paste Code:
wdApp.Selection.Collapse wdCollapseEnd wdApp.Selection.Paste |
|
#2
|
|||
|
|||
|
Like this?
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
Dim r As Range
If Range("c2") = 22 Then wdDoc.Bookmarks("d22").Select
Set r = Selection.Range
r.Collapse wdCollapseEnd
wdApp.Selection.Collapse wdCollapseEnd
wdApp.Selection.Paste
End If
If Range("c2") = 5 Then wdDoc.Bookmarks("d5").Select
Set r = Selection.Range
r.Collapse wdCollapseEnd
wdApp.Selection.Collapse wdCollapseEnd
wdApp.Selection.Paste
End If
If Range("c2") = -20 Then wdDoc.Bookmarks("d20").Select
Set r = Selection.Range
r.Collapse wdCollapseEnd
wdApp.Selection.Collapse wdCollapseEnd
wdApp.Selection.Paste
End If
End Sub
|
|
| Tags |
| bookmark, if statement, vba |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
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 |
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 |