PDA

View Full Version : [WORD] font size in tables



small_badger
03-14-2011, 12:55 AM
Hi everybody.

I want to create a macro which changes font size only in tables not in the free text of the Word document. The point is that I want to start this macro from 3rd table to the end of the Word document.
The problem is I can’t run this macro and I don’t know why it doesn’t work?
May by You will help me, please.

Option Explicit
Sub change_font_size()
Dim x&
Application.ScreenUpdating = False
On Error Resume Next
For x = 1 To ThisDocument.Tables.Count
With ThisDocument.Tables(x).Range.Font
Select Case x
Case 3: .Size = 7
Case Is > 5: .Size = 7
End Select
End With
Next
Application.ScreenUpdating = True
End Sub

Second problem:
This macro is ok, but now I want to start action from 8th page of my Word document. It is possible?

Sub delete_empty_table()

Dim oTable As Table
Dim oRow As Row

For Each oTable In ActiveDocument.Tables
For Each oRow In oTable.Rows
'Check whether row is empty - delete if it is
If Len(oRow.Range.Text) = oRow.Cells.Count * 2 + 2 Then
oRow.Delete
End If
Next oRow
Next oTable
End Sub

fumei
03-14-2011, 01:12 PM
You have some conflicting statements.

a) I want to start action from 8th page of my Word document.
b) For Each oTable In ActiveDocument.Tables

The first has a start (8th page), the second has no start - it processes ALL tables regardless of where they are.

As for starting at the 8th page, you can either place a bookmark at th estrt of the 8th page (but remember it could move), or put the cursor there and process from there to the end of the document. Use Range.

"The problem is I can’t run this macro and I don’t know why it doesn’t work?"

What does that even mean? You can't run it? What happens? Your computer freezes? Word freezes? Word crashes? Nothing happens? Something happens but you do not know what it is? You get error messages? You do not get error messages?

Hopefully the ampersand in Dim x& is a typo. You do not really have & there, do you?

Paul_Hossler
03-14-2011, 02:06 PM
Gerry

22 hours????? :beerchug:



The type-declaration character (http://vbaexpress.com/forum/ms-help://MS.WINWORD.DEV.12.1033/WINWORD.DEV/content/HV01200929.htm) for Long is the ampersand (&).


Not my coding style, since I tend to be wordy, but VBA takes it


Option Explicit
Sub drv()
Dim i&

MsgBox VarType(i)
End Sub


Stop back and visit us

The Word forum won't be the same

Paul

fumei
03-15-2011, 11:02 AM
Yikes. Sorry. I forgot all about that. My bad. I never use it.