Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-08-2014, 12:00 PM
SuzeG SuzeG is offline Using With ActiveDocument.Tables() Windows 7 64bit Using With ActiveDocument.Tables() Office 2010 64bit
Novice
Using With ActiveDocument.Tables()
 
Join Date: Dec 2013
Location: Va Beach
Posts: 21
SuzeG is on a distinguished road
Default Using With ActiveDocument.Tables()


Can With ActiveDocument.Tables() be used only once in a document?
I have several tables in a document that I have different code to perform when the user is in each table.
I use With ActiveDocument.Tables(4) with code following
then With ActiveDocument.Tables(6) with different code and then
With ActiveDocument.Tables(7) with more code.
If not what would I use to perform the code as the user moves through the document?

Thank you.
Reply With Quote
  #2  
Old 01-08-2014, 02:00 PM
gmaxey gmaxey is offline Using With ActiveDocument.Tables() Windows 7 32bit Using With ActiveDocument.Tables() Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,598
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

It can be used repeatedly as long as you close each instance of

With ActiveDocument.Tables(#) ...

with an

End With

statement

Or you might want to run the same code on some multiple tables:

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim lngIndex As Long
 For lngIndex = 1 To ActiveDocument.Tables.Count
  Select Case lngIndex
    Case 1 To 4
      With ActiveDocument.Tables(lngIndex)
        .Cell(1, 1).Range.Text = "A"
      End With
    Case 5, 6
      With ActiveDocument.Tables(lngIndex)
        .Cell(1, 1).Range.Text = "B"
      End With
    Case 7
      With ActiveDocument.Tables(lngIndex)
        .Cell(1, 1).Range.Text = "C"
      End With
  End Select
Next
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply

Tags
tables, vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using With ActiveDocument.Tables() Hopefully you can help RE List of Tables W7PSK Word 6 06-17-2011 06:55 AM
Using With ActiveDocument.Tables() Moving Tables b0x4it Word VBA 9 05-20-2011 01:00 AM
Using With ActiveDocument.Tables() Pictures in Tables uhlersa Word Tables 2 03-21-2011 03:21 PM
Tables and VBA spl3001 Word VBA 0 03-25-2010 02:18 PM
Using With ActiveDocument.Tables() Array into ComboBox + Macro-Text into ActiveDocument Vivi Word VBA 1 01-27-2010 07:03 AM

Other Forums: Access Forums

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