![]() |
#1
|
|||
|
|||
![]()
Hello, I am wondering if it is possible to apply bookmarks to multiple documents (several hundred in this case)? I have a macro that selects a bookmarked cell in a word table and pastes it there. However the document I am pasting into is unique to each performance review. Meaning that technically, each time I run the macro it is pasting into a different document.
Code:
Sub CopyAndPaste() Dim myfile, wdApp As New Word.Application, wdDoc As Word.Document 'select truck report file ChDrive "E:\" ChDir "E:\WG\TVAL\" myfile = Application.GetOpenFilename(, , "Browse for Document") Dim i As Integer 'searches for row with "avg" then selects column E(avg of temperature mean) of that row. i = Application.Match("Avg", Sheet1.Range("A1:A20"), 0) 'copies the cell Range("E" & i).Select Selection.Copy wdApp.Visible = True Set wdDoc = wdApp.Documents.Open(myfile) 'selects the paste range in the performance review table, depending on the set point 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.Collapse wdCollapseEnd wdApp.Selection.Paste End Sub Does anyone know if applying bookmarks can be done universally? and if not, does anyone have a better solution to pasting into a table cell? Here are my previous threads working on this problem: https://www.mrexcel.com/forum/genera...ine-table.html https://www.ozgrid.com/forum/forum/h...ile-within-vba But if you could post solutions in this thread that would be great! |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Having Issues Applying a Macro Across Multiple Files. Changes Just Don't Seem To Save. | Kajex | Word VBA | 2 | 09-08-2017 06:37 AM |
Applying heading style to multiple pages at once | jane.bugai | Word | 5 | 02-24-2017 04:05 PM |
![]() |
PeterPlys | Word VBA | 13 | 01-14-2015 06:41 AM |
![]() |
secoo140 | Excel | 1 | 10-12-2013 07:19 PM |
Publisher 2000 - Applying multiple styles | Jerb | Publisher | 0 | 02-15-2009 10:06 AM |