Adding a row to a protected table - (attn: G. Mayor)

Graham Mayor provides a macro that is extremely helpful to me in a project I 
am working on entitled: "An alternative method of adding a row to a protected 
table
" (http://www.gmayor.com/word_vba_examples.htm).  What I am having trouble 
with is identifying the number of the table.  I have a lengthy document and 
over time some tables have been added or deleted, and I am suspecting that I 
my table numbers are 'out-there.'  I have a commandbutton running the above 
macro and if I tested the macro to add rows to tables 1-4 and it works fine.  
However, I cannot seem to get it to work on tables 5-8 (which may be table 52 
for all I know).

Set oTable = .Tables(1) 'Select the appropriate table

Is there something I am missing.  How can I find out the number of a table 
in my document?  

0
Utf
4/7/2010 7:19:02 PM
word.vba.general 1023 articles. 1 followers. Follow

2 Replies
758 Views

Similar Articles

[PageSpeed] 55

Not really.  The table index is the CURRENT order of tables in the document.
If a table is inserted above, then it gets the previous index.

Table1 (call it Yadda)
Table2 (call it Blah)
Table3 (call it Whatever)

If a new table is inserted above Yadda, it now becomes Table1.

Table1
Table2 (call it Yadda)
Table3 (call it Blah)
Table4 (call it Whatever)

OR.... if a table is moved, then it gets the index number in the order it is
in the document.

Table1 (call it Yadda)
Table2 (call it Blah)
Table3 (call it Whatever)

with Yadda moved to between Blah and Whatever - the index number is changed.

Table1 (call it Blah)
Table2 (call it Yadda)
Table3 (call it Whatever)

What to do?  Here is what I do.  I make each table bookmarked, and of course
bookmarks have NAMES.  If the bookmark is the table, and only one table, then
you can make a table object (named of course) for that table.  Thus, you can
name a table, and because it comes from a bookmark, it does not matter if it
is moved, or if other tables are inserted before it.  Nor does it matter if
add  or subtract rows from the table. Any such changes remain within the
bookmark range, and are automatically covered.

Dim tblYadda As Table
Dim tblBlah As Table
Dim tblWhatever As Table

Set tblYadda = ActiveDocument.Bookmarks("Yadda").Range.Tables(1)
Set tblBlah = ActiveDocument.Bookmarks("Blah").Range.Tables(1)
Set tblWhatever = ActiveDocument.Bookmarks("Whatever").Range.Tables(1)

As these are now table OBJECTS, all properties are available.

tblYadda.Cell(2,3).Range.Text = "some text"

"add rows to tables 1-4 and it works fine.  However, I cannot seem to get it
to work on tables 5-8 (which may be table 52 for all I know).

Exactly.  It could be Table52, or Table6, or Table23.  If you have a lot of
tables, and you need to work with them a lot, bookmark them, and then use
table objects.  You will never have to concern yourself with WHERE they are,
or how may rows they have...ever again.

Gerry

Bigfoot17 wrote:
>Graham Mayor provides a macro that is extremely helpful to me in a project I 
>am working on entitled: "An alternative method of adding a row to a protected 
>table
>" (http://www.gmayor.com/word_vba_examples.htm).  What I am having trouble 
>with is identifying the number of the table.  I have a lengthy document and 
>over time some tables have been added or deleted, and I am suspecting that I 
>my table numbers are 'out-there.'  I have a commandbutton running the above 
>macro and if I tested the macro to add rows to tables 1-4 and it works fine.  
>However, I cannot seem to get it to work on tables 5-8 (which may be table 52 
>for all I know).
>
>Set oTable = .Tables(1) 'Select the appropriate table
>
>Is there something I am missing.  How can I find out the number of a table 
>in my document?

-- 
Gerry

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/201004/1

0
Fumei2
4/7/2010 7:50:54 PM
I cannot begin to tell you haw helpful this response has been.  You did more 
than just answer the question you instructed, very helpful.  As a result I 
could explore more and learned more about my situation and why I was having 
problems.

First, I found I could indeed, identify the table numbers because they are 
always in order. Second, I learned why the macro that was running sucessfully 
on tables 1-4 adding an additional row, with formfields, and would not run on 
tables 5-8 was happening for a good reason.  Tables 5-8 had merged cells in 
the last row (vertically).  For instance Column 3, rows 2 and 3 were merged 
so the macro would not work. 

Thanks. I'm learning.

"Fumei2 via OfficeKB.com" wrote:

> Not really.  The table index is the CURRENT order of tables in the document.
> If a table is inserted above, then it gets the previous index.
> 
> Table1 (call it Yadda)
> Table2 (call it Blah)
> Table3 (call it Whatever)
> 
> If a new table is inserted above Yadda, it now becomes Table1.
> 
> Table1
> Table2 (call it Yadda)
> Table3 (call it Blah)
> Table4 (call it Whatever)
> 
> OR.... if a table is moved, then it gets the index number in the order it is
> in the document.
> 
> Table1 (call it Yadda)
> Table2 (call it Blah)
> Table3 (call it Whatever)
> 
> with Yadda moved to between Blah and Whatever - the index number is changed.
> 
> Table1 (call it Blah)
> Table2 (call it Yadda)
> Table3 (call it Whatever)
> 
> What to do?  Here is what I do.  I make each table bookmarked, and of course
> bookmarks have NAMES.  If the bookmark is the table, and only one table, then
> you can make a table object (named of course) for that table.  Thus, you can
> name a table, and because it comes from a bookmark, it does not matter if it
> is moved, or if other tables are inserted before it.  Nor does it matter if
> add  or subtract rows from the table. Any such changes remain within the
> bookmark range, and are automatically covered.
> 
> Dim tblYadda As Table
> Dim tblBlah As Table
> Dim tblWhatever As Table
> 
> Set tblYadda = ActiveDocument.Bookmarks("Yadda").Range.Tables(1)
> Set tblBlah = ActiveDocument.Bookmarks("Blah").Range.Tables(1)
> Set tblWhatever = ActiveDocument.Bookmarks("Whatever").Range.Tables(1)
> 
> As these are now table OBJECTS, all properties are available.
> 
> tblYadda.Cell(2,3).Range.Text = "some text"
> 
> "add rows to tables 1-4 and it works fine.  However, I cannot seem to get it
> to work on tables 5-8 (which may be table 52 for all I know).
> 
> Exactly.  It could be Table52, or Table6, or Table23.  If you have a lot of
> tables, and you need to work with them a lot, bookmark them, and then use
> table objects.  You will never have to concern yourself with WHERE they are,
> or how may rows they have...ever again.
> 
> Gerry
> 
> Bigfoot17 wrote:
> >Graham Mayor provides a macro that is extremely helpful to me in a project I 
> >am working on entitled: "An alternative method of adding a row to a protected 
> >table
> >" (http://www.gmayor.com/word_vba_examples.htm).  What I am having trouble 
> >with is identifying the number of the table.  I have a lengthy document and 
> >over time some tables have been added or deleted, and I am suspecting that I 
> >my table numbers are 'out-there.'  I have a commandbutton running the above 
> >macro and if I tested the macro to add rows to tables 1-4 and it works fine.  
> >However, I cannot seem to get it to work on tables 5-8 (which may be table 52 
> >for all I know).
> >
> >Set oTable = .Tables(1) 'Select the appropriate table
> >
> >Is there something I am missing.  How can I find out the number of a table 
> >in my document?
> 
> -- 
> Gerry
> 
> Message posted via OfficeKB.com
> http://www.officekb.com/Uwe/Forums.aspx/word-programming/201004/1
> 
> .
> 
0
Utf
4/9/2010 6:58:02 PM
Reply:

Similar Artilces:

Adding Blank Rows after the last Detail of the Report
Hi All, I've used this code from Dwayne: Private Sub Report_Page() Dim intNumLines As Integer Dim intLineNumber As Integer Dim intTopMargin As Integer Dim ctl As Control Dim intLineHeight As Integer intNumLines = 12 intTopMargin = Me.Section(3).Height intLineHeight = Me.Section(0).Height For Each ctl In Me.Section(0).Controls For intLineNumber = 0 To intNumLines - 1 Me.Line (ctl.Left, intTopMargin + _ (intLineNumber * intLineHeight)) - _ Step(ctl.Width, intLineHeight), , B Next Next End Sub My report needs to print blank rows (at least...

Adding hyperlinks with parameters
Hey everybody I have a batch file which needs to be run from an excel sheet with a parameter, like this: c:\1.bat myParameter But when i try to run the Hyperlink, the Excel shows an error message saying it can't open the specified file (probably because the is a space between the file and the parameter) is there any known way to run the link from the excel? On Mar 2, 12:45=A0pm, Pasha <pavel_v...@mailto.mod.gov.il> wrote: > Hey everybody > I have a batch file which needs to be run from an excel sheet with a > parameter, like this: > c:\1.bat myParameter > But when i ...

Scrolling rows
Ok, don't laugh. I want to know how to set up a row that will stay at the top of the screen when I scroll down the spreadsheet. An example would be Name, address, city, state, zip. I want to be able to keep these cells at the top when I scroll down looking at the data. Does this make sense? Thanks, C- If your Headings are in Row 1, click into Cell A2. Then go to Window | Freeze Panes. tj "C-" wrote: > Ok, don't laugh. I want to know how to set up a row that will stay at the top > of the screen when I scroll down the spreadsheet. An example would be Name, > ...

outlook vcard, ad integration user properties
my boss is trying to get hix fax# in his vcard. he is using his address from the global address list I have modified his profile in active directory users and computers: I go into AD users and computers, double click on his user, go to the telephones tab, and enter his fax #. but when I did this his fax # is still not being pulled up in his outlook vcard. Does anyone know where outlook is trying to get this field from / how i can get this field into his vcard? thx ...

table design question
I have table of 40 milion rows (sql 2005). There is one column, Id, which is integer (basically month), and there are 20 different values for this column (around 2 million rows per id value). At the same time, there is very long primary key on this table (12 columns, around 400 bytes), and nonclustered index on this primary key. Table is being accessed frequently by Id, so I created clustered index on this column (usually, developers create temporary tables per id, and then do further processing) to lower physical reads... Does this sound like a desirable design? I don't wan...

ADDING A NUMBER
how do i add a number to a range of cells? I need to add 11.27 to a number of different cells each with a different number in them Put 11.27 in an empty cell, format it the same way as the numbers you want to add to, copy it, then select the numbers you want to add to and do edit>paste special and select add. -- Regards, Peo Sjoblom "Helpme" <Helpme@discussions.microsoft.com> wrote in message news:6D51344A-78E6-4377-B292-FC6C16FF6BA2@microsoft.com... > how do i add a number to a range of cells? I need to add 11.27 to a > number > of different cells e...

When adding attachments...
....in Outlook the following errors comes up: "Out of memory or system resources, please close some programs and try again" Quotas are fine. I have deinstalled/reinstalled Office, cleaned 'temp' areas, and many other tidbits. Any other ideas? Thanks. This might help as i had this problem with Outlook 98. Is the file you are trying to copy to attach nested in sub folders? if so try and copy the attachment to a root drive like c:\ Ignore previous email. wrong spellin if the attachment is nested in sub folders(this means you have to open different folders to get to ...

Linking to a Password Protected Document in Excel 2000
I have a document that is password protected. I also have a file that references the protected files for many of the its formulas. Each time I open the file and update the links I am prompted multiple times (once for each cell reference to the protected file) for the password. Is there any setting so that a user is only prompted once for the password to a reference file that is protected? I know that one option is just to copy the tabs from my referencing file into the protected file, but it would be nice to keep the documents separate. Thanks, Andrew One option might be to disable th...

adding new records
I am totally new to CRM, so I hope this is really easy question: This concerns permissions.. I have a "sales" group, and with one of those people i need to be able to let them add new records on behalf of other "sales" people. Is there like a standard permission setting for it? (obviously every "sales" person can add new records if they select them selfs as the owner) thanks, Michal. Hi, By default the person who creates the record will be the owner. After record creation the person could reassign the record (manually) to another user. If all rec...

In Excel I have a workbook, and want to select all blank rows for.
I have a worksheet with around 19,000 rows, some of which are blank. It's a price list I do regularly. How can I select all blank rows and then delete them. It will take hours to do them all manually. Hi see: http://www.cpearson.com/excel/deleting.htm#DeleteBlankRows -- Regards Frank Kabel Frankfurt, Germany "HANDY ANDY" <HANDY ANDY@discussions.microsoft.com> schrieb im Newsbeitrag news:FC815E8C-813A-48EA-94A3-26E8B22F8EB4@microsoft.com... > I have a worksheet with around 19,000 rows, some of which are blank. It's a > price list I do regularly. How can ...

Picture Disappears When Added To Contact In Outlook 2003
Can someone help please. When I try to attach a picture to a contact in outlook 2003 immediately I double click the picture to be attached it disappears out of the outlook contact along with the placement holder in the form. Only when I right click the mouse and go remove picture do I get the placement holder back. I have looked at all the help menus but they offer no clues. Thanks TS ...

grouping in Excel Pivot table
currently i am using pivot table to calculate the grand total for ageing day in my report. The ageing day are 1, 2, 3 to 6 days and > 6 days that i want to group together. In pivot table, it can only able to calculate the grand total like total ageing for 1 day, 2 days, 3 days.... and go on. Is there any way that pivot table will do what i want or you guys can suggest any other method? I am aware of group function in pivot table but it cannot suit my needs. Thanks Lim Heng Sin All sorts of data can be analysed by adding another column to the base data and using the new field in ...

Adding ActiveX to dialog with wrapper
When I add an ActiveX object to a dialog using the dialog editor - right click - insert activeX object, the help on the resulting activex selection tool states that a wrapper will not be added by using this method. If you need a wrapper, it suggests using the class view. This is using Visual Studio 2005. I'm having some problems with this on an existing project. To make sure I understand the process, I created a new MFC project, added a dialog, created a class for that dialog and added a Flexgrid object using the right click method in the dialog. I then added a variable for the flexgrid...

Adding alternate columns
I work on a schedule where I record ticket count and ticket sales for each show, listed chronologically. Column A = week ending date Column B = # Tickets sold for April 5 show Column C = Ticket Revenue for April 5 show Column D = # Tickets sold for April 9 show Column E = Ticket Revenue for April 9 show Column F = # Tickets sold for April 12 show Column G = Ticket Revenue for April 12 show Column H = Total # Tickets sold for all shows Column I = Total Ticket Revenue for all shows In the Totals columns, the Total Tickets formula is "+B4+D4+F4", and the Total Revenue f...

Merge and Center Multiple Rows
I have two rows of numbers. After doing some comparisons, I want to send this spreadsheet to the customer with JUST the value for each column that we want them to see. Currently, we are going to the two side-by-side columns, deleting the number that we don't want them to see, then highlighting both cells and clicking on the merge and center button on the toolbar. This is all fine and dandy if you're doing one or two rows of data....but we've got pages and pages we have to do this to. My question is two-fold - I know about the STUPID error "The cell reference for a merged c...

Adding fields from a different query
I have a form built based on a main query. How do I add more fields on that form that come from a different query? Anne A couple possibilities... Change your first query to include the extra fields. Use your second query to "feed" a form, then embed that form as a subform on your main form. Good luck! Regards Jeff Boyce Microsoft Access MVP -- Disclaimer: This author may have received products and services mentioned in this post. Mention and/or description of a product or service herein does not constitute endorsement thereof. Any code or pseudoco...

Adding more than three Conditions to 'Conditional Formatting'
Can i add more than three conditions to the conditional formatting presets using code? Regards [Riz] -- Rizitsu ------------------------------------------------------------------------ Rizitsu's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=15840 View this thread: http://www.excelforum.com/showthread.php?threadid=320382 Riz, as you have found out, only 3 conditions with conditional formatting. But yes you can use some code to get more than 3, try this it will change the cell color in column A when you put in one ,two, three, or four, right click on the she...

Insert Comments on a Protected Worksheet
hi - I have a worksheet with areas that are locked, and a range B5:H23 that is not locked. Protection has been applied to the sheet. The user is allowed to SELECT unlocked cells. My problem is that I want to be able to INSERT COMMENTS in the unlocked range. I can't seem to do this while protection is ON. (Comments can only be added when Protection is OFF) What am I missing? thanks in advance -- cinnie When setting sheet protection allow users to "Edit Objects"........down near bottom of list. Then you can Insert Comments in unlocked cells. Gord ...

Delimiter for adding Appointment in Entourage
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Power PC Email Client: Exchange What's the delimiter that Entourage uses if I want to add an appointment and the subject needs to be parsed by the Exchange server? <br><br>In Outlook, the hash/pound key (#) is used as delimiter. How about in Entourage 2008? <br><br>Basically, if I add an entry in a group calendar Out-Of-Office with the subject: #User1# On-Leave <br><br>in Outlook, this entry appears in the group calendar Out-Of-Office and also in User1's personal calendar. <...

AD Monitoring
Is there a listing somewhere of what all components in AD should be minitored, thresholds, etc...we are evaluating a monitoring solution and need this information to take a decision on the product to use Hello Sameer, For performance start here: http://technet.microsoft.com/en-us/library/cc961943.aspx Also see: http://technet.microsoft.com/en-us/library/bb727046.aspx Use the included links from: http://technet.microsoft.com/en-us/library/cc739728(WS.10).aspx Best regards Meinolf Weber Disclaimer: This posting is provided "AS IS" with no warranties, and c...

Adding Terms & Conditions to the Quote Form
We have a client that would like to add their Terms & Conditions (T&C) text to the bottom of their GP Quotes. I've read that static text boxes in Report Designer can only be 80 characters, so that won't work as the T&C text is approximately 4-5 pages long. Does anyone have any suggestions on how to add this significant amount of text to a GP form? Thank you in advance. Scott No can do Scott - Report Writer is just not capable of this. The best solution is to purchase Accountable Software's Forms Printer - www.accountable.com. Frank Hamelly MCP-GP, MCT, MVP East...

Downloaded payees automatically added to payee list
Please tell me that in Money 2006, Microsoft has finally fixed the bug where the payees in my downloaded transactions are automatically added to my payee list (this despite the fact that I've checked off the option "Confirm new payees"). This alone would be worth the upgrade. On the subject of 2006, does anyone know if Microsoft added the cookie jar concept to accounts? The cookie jar allows you to squirrel money away within an account. TIA greg.block@gmail.com wrote: >Please tell me that in Money 2006, Microsoft has finally fixed the bug >where the payees in my downlo...

Flipping naming conventions to match two tables
I have Table #1 that has the name field shown as "First Last". Table #2 has been randomly keyed in by someone with the names as: "First Last", and others "Last First" and yet others that are: "Last, Middle, First." I attempted to try the instructions from a post here labeled "Fuzzy search." However, the MID function does not work due to the random naming conventions keyed in Table 2. Is there another way I can program a query to conform Table 2 so that it matches the consistent naming conventions of Table #1? Guitarzann, ...

CListCtrl and row highlight
Hi All, I have a question regarding CListCtrl. When a list control has entries in it and a user clicks on a row (i.e. the control has focus) then that row is highlighted. However as soon as the control loses focus (i.e. a user clicks on some other control) then the row's highlight colour changes by default. Is it possible to disable this so that the row is still highlighted in exactly the same colour regardless of whether it has focus or not? Thanks in advance for any help anyone can pass on. Paul Hi, add style LVS_SHOWSELALWAYS Bye, Holger. Check the following example: http...

Adding Collapse/Expand to Publisher 2003 items
Hi I'm trying to enter a text box which may be expanded/Collapsed as follows: > More Info... > Next Item... > More Info... When you want bla bla bla, do bla bla bla, > Next Item... Can anyone tell me how to implement it?! Thank you 'bla bla bla' is the sound of geckos mating - so the naturalists tell me. No, you cannot do what you want. Your answer is rude & arrogant. I don't know why would anyone put you in a position to Accept calls for help. Besides - I don't believe it can't be done. Please don't call again "*...