Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-15-2019, 06:19 AM
gmaxey gmaxey is offline Table named after first cell Windows 10 Table named after first cell Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Well, the solution provided by Macropod does not bookmark the table with the content of the first cell. You are wasting a lot of other people's time by not being clear on what you want.
Code:
Sub Demo()
Dim lngIndex As Long
Dim oTbl As Table
  For lngIndex = 2 To ActiveDocument.Tables.Count
    Set oTbl = ActiveDocument.Tables(lngIndex)
    With oTbl
       .Range.Bookmarks.Add Replace(Split(.Cell(1, 1).Range.Text, vbCr)(0), " ", "_"), .Range
    End With
  Next lngIndex
End Sub

__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #2  
Old 05-15-2019, 04:07 PM
macropod's Avatar
macropod macropod is offline Table named after first cell Windows 7 64bit Table named after first cell 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 gmaxey View Post
Well, the solution provided by Macropod does not bookmark the table with the content of the first cell.
Given that bookmarks cannot contain spaces (which the OP subsequently clarified) or paragraph breaks (which your code doesn't handle at all), my code goes as close as is possible. I do agree, though, that the specifications were lacking.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
bookmark, table



Similar Threads
Thread Thread Starter Forum Replies Last Post
Use of named ranges based on cell content Intruder Excel 12 02-25-2019 09:42 AM
save selected worksheets, named by cell value rossmortimore Excel 1 12-27-2018 01:56 PM
Table named after first cell Code to find a named (bookmarked?) table, replicate a row or table, and delete a specified table. kevinbradley57 Word VBA 9 09-21-2017 04:58 PM
Table named after first cell how do i use a named cell for each worksheet cwkotch Excel 3 11-03-2015 09:04 AM
Can't use a zero in a named cell TechEd Excel 2 10-16-2012 10:06 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:53 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