Hide Rows in Table

L

Liakamai

When I run the sub below it works fine. However when I call it from
Document_Open() it gets ugly.

Call this sub from Document_Open() and you'll see what I mean

Sub Document_Open()
call HideRows()
end sub

Thanks in advance for any advise.

Sub HideRows()
Dim i As Integer
i = 1
For i = 1 To 13
ActiveDocument.Tables(1).Rows(i).Range.Font.Hidden = True
Next
End Sub
 
J

Jean-Guy Marcil

When I run the sub below it works fine. However when I call it from
Document_Open() it gets ugly.

Call this sub from Document_Open() and you'll see what I mean

Sub Document_Open()
call HideRows()
end sub

Thanks in advance for any advise.

Sub HideRows()
Dim i As Integer
i = 1
For i = 1 To 13
ActiveDocument.Tables(1).Rows(i).Range.Font.Hidden = True
Next
End Sub

I tried your code as is with a document I saved with a 15-row table.

It worked as expected, nothing ugly.

It is never helpful to just states that "it does not work", or "there is a
problem", or "it gets ugly", etc.
Also, mentioning the Word version may be useful.

Finally, always state the expectations and the observed behaviour. this way
we can actually help. It saves everybody time, and it will encourage more
people to actually try to help.
 
L

Liakamai

I tried your code as is with a document I saved with a 15-row table.

It worked as expected, nothing ugly.

It is never helpful to just states that "it does not work", or "there is a
problem", or "it gets ugly", etc.
Also, mentioning the Word version may be useful.

Finally, always state the expectations and the observed behaviour. this way
we can actually help. It saves everybody time, and it will encourage more
people to actually try to help.- Hide quoted text -

- Show quoted text -

Thank you for your quick response and apologize for not being more
clear.

Like you, I tried the above sub on a test document and it worked
perfectly. I apologize for not being more clear.

I am using Word 2003. The VBA has about 200 lines of code. When I call
the sub HideRows from sub Document_Open I observe the behavior below:

Observed behavior: When call HideRows from Sub Document_Open() and ,
the application removes 5 of the rows and only text from the other 8.

Rows with Labels and Radio buttons are not removed.
Rows without Labels and Radio buttons are removed.

when I run sub HideRows alone it works perfectly.

Expectations: I would the called sub HideRows to work as it does when
running it alone.

Thanks again.
 
J

Jean-Guy Marcil

Thank you for your quick response and apologize for not being more
clear.

Like you, I tried the above sub on a test document and it worked
perfectly. I apologize for not being more clear.

I am using Word 2003. The VBA has about 200 lines of code. When I call
the sub HideRows from sub Document_Open I observe the behavior below:

Observed behavior: When call HideRows from Sub Document_Open() and ,
the application removes 5 of the rows and only text from the other 8.

Rows with Labels and Radio buttons are not removed.
Rows without Labels and Radio buttons are removed.

By Radio Buttons and Labels, you mean ActiveX controls from the Control
Toolbar, right?
In my tests, also with Word 2003, this is what I used, I placed a few of
them in the first 13 rows, all of them with an "in line with text" wrapping.
when I run sub HideRows alone it works perfectly.

Same here.
Expectations: I would the called sub HideRows to work as it does when
running it alone.

On my machine, it works equally well, whther I call it from a Document_Open
sub or if I call it directly with ALT-F8 after opening the odcument.

My guess is that you have some other code in your 200 lines that interferes...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top