![]() |
|
#1
|
|||
|
|||
![]()
If I wanted to use word table cell selection, how would I implement it? I know Macropod has suggested using bookmarks to select any cell, but from what it seems I will not be able to use bookmarks for this and instead am trying to identify the table cells to paste into. Here is what I have
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 wdoc.tables(7).Cell("B4").Select If Range("c2") = 5 Then wdoc.tables(7).Cell("C4").Select If Range("c2") = -20 Then wdoc.tables(7).Cell("D4").Select 'and paste the clipboard contents wdApp.Selection.Collapse wdCollapseEnd wdApp.Selection.Paste End Sub |
#2
|
||||
|
||||
![]()
Aside from the fact there is rarely any need to select anything - and no need to do so for what you've posted so far - there is also nothing about what you've posted to indicate why you wouldn't be able to employ a bookmark.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
I can not use bookmarks because per my original question in this thread was how to apply bookmarks to ALL the word docs that I will be using this macro for. As I never got an answer if I would be able to apply bookmarks across an entire folder of doc templates, I am not going to be able to use them to reference cells.
|
#4
|
||||
|
||||
![]()
Doing that is trivial - but so too is referencing tables without recourse to bookmarks. Since nothing is already bookmarked and you'd have to know which table to bookmark anyway, the bookmarking seems pointless. Either way, there is no need to select anything...
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
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 |