Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-20-2018, 07:32 AM
klutch klutch is offline Applying bookmarks to multiple documents - is it possible? Windows 7 32bit Applying bookmarks to multiple documents - is it possible? Office 2016 for Mac
Advanced Beginner
Applying bookmarks to multiple documents - is it possible?
 
Join Date: Jun 2018
Posts: 31
klutch is on a distinguished road
Default

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
With this code I am getting a "object required" error on this line: If Range("c2") = 5 Then wdoc.tables(7).Cell("C4").Select
Reply With Quote
  #2  
Old 06-20-2018, 08:12 PM
macropod's Avatar
macropod macropod is online now Applying bookmarks to multiple documents - is it possible? Windows 7 64bit Applying bookmarks to multiple documents - is it possible? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by klutch View Post
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
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]
Reply With Quote
  #3  
Old 06-20-2018, 08:23 PM
klutch klutch is offline Applying bookmarks to multiple documents - is it possible? Windows 7 32bit Applying bookmarks to multiple documents - is it possible? Office 2016 for Mac
Advanced Beginner
Applying bookmarks to multiple documents - is it possible?
 
Join Date: Jun 2018
Posts: 31
klutch is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
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.
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.
Reply With Quote
  #4  
Old 06-20-2018, 08:46 PM
macropod's Avatar
macropod macropod is online now Applying bookmarks to multiple documents - is it possible? Windows 7 64bit Applying bookmarks to multiple documents - is it possible? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by klutch View Post
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.
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]
Reply With Quote
Reply



Similar Threads
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
Applying bookmarks to multiple documents - is it possible? Form updating Bookmarks - writes to the bookmarks multiple times PeterPlys Word VBA 13 01-14-2015 06:41 AM
Applying bookmarks to multiple documents - is it possible? Applying a conditional format to multiple rows secoo140 Excel 1 10-12-2013 07:19 PM
Publisher 2000 - Applying multiple styles Jerb Publisher 0 02-15-2009 10:06 AM

Other Forums: Access Forums

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


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