Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-07-2011, 06:32 AM
hklein hklein is offline names of tables Windows XP names of tables Office 2007
Novice
names of tables
 
Join Date: Jul 2011
Posts: 23
hklein is on a distinguished road
Default names of tables

Dear All,



I would like to, how to get the name of a table? I red earlier, that it is listed in its properties, but I didn't find it.
Can anybody help?

Thank you
Reply With Quote
  #2  
Old 11-08-2011, 01:57 AM
macropod's Avatar
macropod macropod is offline names of tables Windows 7 64bit names of tables Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Hi hklein,

Tables don't have a 'name' property. They do, however, have a 'title' property which you can access via 'Alt Text' on the tables properties dialogue box.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 11-14-2011, 01:04 AM
hklein hklein is offline names of tables Windows XP names of tables Office 2007
Novice
names of tables
 
Join Date: Jul 2011
Posts: 23
hklein is on a distinguished road
Default

Thank you, but I don't understand it. How to do it?

In fact, what I need is to define exactly a table in my macro. Index is not the way I could use, as I have to use different templates, where tables for same purposes have different indexes. I do not want to change the code due to the different index, but would like to locate the table by an exact property. If you know, how to change the index to an other value, it is fine for me as well.

Thanks
Reply With Quote
  #4  
Old 11-14-2011, 01:11 AM
macropod's Avatar
macropod macropod is offline names of tables Windows 7 64bit names of tables Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Hi hklein,

If you give the table a 'title', you can refer to it in code by that. Alternatively, if the table has some distinguishing feature (eg a particular heading), you can use that. Either way, you'll have to loop through the tables to find the one that matches your criteria.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 11-14-2011, 02:10 AM
hklein hklein is offline names of tables Windows XP names of tables Office 2007
Novice
names of tables
 
Join Date: Jul 2011
Posts: 23
hklein is on a distinguished road
Default

Hi
can you pls show me a coding example, how to give a 'title" toa table?

How to change the
activedocument.tables(1) to activedocument("mytable")

Thank you
Reply With Quote
  #6  
Old 11-14-2011, 04:19 AM
macropod's Avatar
macropod macropod is offline names of tables Windows 7 64bit names of tables Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Hi hklein,

To add a title programmatically, you could use code like:
Code:
Sub Demo1()
ActiveDocument.Tables(1).Title = "MyTableTitle"
End Sub
However, if you know which table to add the title to programmatically without selecting it, you probably don't need to give it a title.

Alternatively, if you want to add a title to a selected table, you can do that through the user interface, or with code like:
Code:
Sub Demo2()
If Selection.Information(wdWithInTable) = False Then Exit Sub
Selection.Tables(1).Title = "MyTableTitle"
End Sub
Ultimately, though you'll want to do something programmatically with the titled table, for which you'll need more sophisticated code, like:
Code:
Sub Demo3()
Dim oTbl As Table
For Each oTbl In ActiveDocument.Tables
  If oTbl.Title = "MyTableTitle" Then
    'Do something with the table
    Exit For
  End If
Next
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 11-16-2011, 06:50 AM
hklein hklein is offline names of tables Windows XP names of tables Office 2007
Novice
names of tables
 
Join Date: Jul 2011
Posts: 23
hklein is on a distinguished road
Default

Hi Macropod,

many thanks for your help, I really appreciate it.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
chart names in PP ? Intruder PowerPoint 0 12-24-2010 06:05 AM
Names 2007 shadad Excel 0 03-19-2010 02:53 PM
Names dguillory Word 0 12-29-2009 11:00 PM
Display names Ineedhelp Outlook 1 05-12-2009 11:28 PM
Two Different Names in the Same File kathy carson Outlook 0 02-14-2006 01:02 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:06 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft