Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
macro table width (in Word)
I have a word formate template, used for theseses. It's based on an old
format for theseses. In the template there are a few macros too. (I didn't create them). One of them is a table format macro, working fine. (Copied from the former template.) Problem is (in former and in new template) that tables are too wide. The left vertical line is too far out to the left (in the margin). (Since top and bottom lines are visible they stick out...) I've managed to record a macro of my own, same table format. While recording the macro it seems like I manage to change the width, but when running the macro it's too wide again. So probably I'm only changing that exact table, and not the macro itself. The code doesn't help me either. The old table macro is very simple, while the one I make myself contains every single move I make... so I can't even compare the code. (But since both tables are too wide it doesn't matter.) [And why is code so different...?] I'd really appreciate some help (code below). Lynn (not Lyn in thread). OLD CODE Selection.Tables(1).Select With Selection.Tables(1) .Borders(wdBorderLeft).LineStyle = wdLineStyleNone .Borders(wdBorderRight).LineStyle = wdLineStyleNone With .Borders(wdBorderTop) .LineStyle = wdLineStyleSingle .LineWidth = wdLineWidth050pt .ColorIndex = wdAuto End With With .Borders(wdBorderBottom) .LineStyle = wdLineStyleSingle .LineWidth = wdLineWidth050pt .ColorIndex = wdAuto End With .Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone .Borders(wdBorderVertical).LineStyle = wdLineStyleNone .Borders.Shadow = False End With With Options .DefaultBorderLineStyle = wdLineStyleSingle .DefaultBorderLineWidth = wdLineWidth050pt .DefaultBorderColorIndex = wdAuto End With Selection.Style = ActiveDocument.Styles("Tabelltext") End Sub NEW CODE (I also tried to add second horizontal line visible) ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=4, NumColumns:= _ 3, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _ wdAutoFitWindow With Selection.Tables(1) If .Style "Tabellrutnät" Then .Style = "Tabellrutnät" End If .ApplyStyleHeadingRows = True .ApplyStyleLastRow = True .ApplyStyleFirstColumn = True .ApplyStyleLastColumn = True End With Selection.MoveRight Unit:=wdCharacter, Count:=3, Extend:=wdExtend Selection.MoveLeft Unit:=wdCharacter, Count:=2, Extend:=wdExtend Selection.MoveRight Unit:=wdCharacter, Count:=2, Extend:=wdExtend Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend Selection.Borders(wdBorderTop).LineStyle = wdLineStyleNone Selection.Borders(wdBorderLeft).LineStyle = wdLineStyleNone Selection.Borders(wdBorderBottom).LineStyle = wdLineStyleNone Selection.Borders(wdBorderRight).LineStyle = wdLineStyleNone Selection.Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone Selection.Borders(wdBorderVertical).LineStyle = wdLineStyleNone Selection.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone Selection.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone Selection.MoveDown Unit:=wdLine, Count:=1 Selection.MoveUp Unit:=wdLine, Count:=1 Selection.MoveRight Unit:=wdCharacter, Count:=3, Extend:=wdExtend With Selection.Borders(wdBorderBottom) .LineStyle = Options.DefaultBorderLineStyle .LineWidth = Options.DefaultBorderLineWidth .Color = Options.DefaultBorderColor End With Selection.MoveUp Unit:=wdLine, Count:=3 Selection.MoveRight Unit:=wdCharacter, Count:=3, Extend:=wdExtend With Selection.Borders(wdBorderBottom) .LineStyle = Options.DefaultBorderLineStyle .LineWidth = Options.DefaultBorderLineWidth .Color = Options.DefaultBorderColor End With With Selection.Borders(wdBorderTop) .LineStyle = Options.DefaultBorderLineStyle .LineWidth = Options.DefaultBorderLineWidth .Color = Options.DefaultBorderColor End With Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend Selection.Style = ActiveDocument.Styles("Tabelltext") Selection.MoveRight Unit:=wdCharacter, Count:=4 Selection.MoveUp Unit:=wdLine, Count:=1 Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend Selection.MoveRight Unit:=wdCharacter, Count:=1 Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend Selection.Tables(1).Columns(3).SetWidth ColumnWidth:=115.3, RulerStyle:= _ wdAdjustNone Selection.MoveLeft Unit:=wdCharacter, Count:=3 Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend Selection.Tables(1).Rows.SetLeftIndent LeftIndent:=0.65, RulerStyle:= _ wdAdjustNone With Selection.Tables(1) .TopPadding = CentimetersToPoints(0) .BottomPadding = CentimetersToPoints(0) .LeftPadding = CentimetersToPoints(0.1) .RightPadding = CentimetersToPoints(0.1) .Spacing = 0 .AllowPageBreaks = True .AllowAutoFit = True End With Selection.Tables(1).Rows.LeftIndent = CentimetersToPoints(0.1) Selection.MoveDown Unit:=wdLine, Count:=2 Selection.MoveRight Unit:=wdCharacter, Count:=1 Selection.MoveUp Unit:=wdLine, Count:=2 Selection.MoveRight Unit:=wdCharacter, Count:=2 End Sub |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
macro table width (in Word)
I thought I answered a thread... (my remark about the name). Obv. started a
new one =) "Lynn" skrev: I have a word formate template, used for theseses. It's based on an old format for theseses. In the template there are a few macros too. (I didn't create them). One of them is a table format macro, working fine. (Copied from the former template.) Problem is (in former and in new template) that tables are too wide. The left vertical line is too far out to the left (in the margin). (Since top and bottom lines are visible they stick out...) I've managed to record a macro of my own, same table format. While recording the macro it seems like I manage to change the width, but when running the macro it's too wide again. So probably I'm only changing that exact table, and not the macro itself. The code doesn't help me either. The old table macro is very simple, while the one I make myself contains every single move I make... so I can't even compare the code. (But since both tables are too wide it doesn't matter.) [And why is code so different...?] I'd really appreciate some help (code below). Lynn (not Lyn in thread). OLD CODE Selection.Tables(1).Select With Selection.Tables(1) .Borders(wdBorderLeft).LineStyle = wdLineStyleNone .Borders(wdBorderRight).LineStyle = wdLineStyleNone With .Borders(wdBorderTop) .LineStyle = wdLineStyleSingle .LineWidth = wdLineWidth050pt .ColorIndex = wdAuto End With With .Borders(wdBorderBottom) .LineStyle = wdLineStyleSingle .LineWidth = wdLineWidth050pt .ColorIndex = wdAuto End With .Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone .Borders(wdBorderVertical).LineStyle = wdLineStyleNone .Borders.Shadow = False End With With Options .DefaultBorderLineStyle = wdLineStyleSingle .DefaultBorderLineWidth = wdLineWidth050pt .DefaultBorderColorIndex = wdAuto End With Selection.Style = ActiveDocument.Styles("Tabelltext") End Sub NEW CODE (I also tried to add second horizontal line visible) ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=4, NumColumns:= _ 3, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _ wdAutoFitWindow With Selection.Tables(1) If .Style "Tabellrutnät" Then .Style = "Tabellrutnät" End If .ApplyStyleHeadingRows = True .ApplyStyleLastRow = True .ApplyStyleFirstColumn = True .ApplyStyleLastColumn = True End With Selection.MoveRight Unit:=wdCharacter, Count:=3, Extend:=wdExtend Selection.MoveLeft Unit:=wdCharacter, Count:=2, Extend:=wdExtend Selection.MoveRight Unit:=wdCharacter, Count:=2, Extend:=wdExtend Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend Selection.Borders(wdBorderTop).LineStyle = wdLineStyleNone Selection.Borders(wdBorderLeft).LineStyle = wdLineStyleNone Selection.Borders(wdBorderBottom).LineStyle = wdLineStyleNone Selection.Borders(wdBorderRight).LineStyle = wdLineStyleNone Selection.Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone Selection.Borders(wdBorderVertical).LineStyle = wdLineStyleNone Selection.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone Selection.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone Selection.MoveDown Unit:=wdLine, Count:=1 Selection.MoveUp Unit:=wdLine, Count:=1 Selection.MoveRight Unit:=wdCharacter, Count:=3, Extend:=wdExtend With Selection.Borders(wdBorderBottom) .LineStyle = Options.DefaultBorderLineStyle .LineWidth = Options.DefaultBorderLineWidth .Color = Options.DefaultBorderColor End With Selection.MoveUp Unit:=wdLine, Count:=3 Selection.MoveRight Unit:=wdCharacter, Count:=3, Extend:=wdExtend With Selection.Borders(wdBorderBottom) .LineStyle = Options.DefaultBorderLineStyle .LineWidth = Options.DefaultBorderLineWidth .Color = Options.DefaultBorderColor End With With Selection.Borders(wdBorderTop) .LineStyle = Options.DefaultBorderLineStyle .LineWidth = Options.DefaultBorderLineWidth .Color = Options.DefaultBorderColor End With Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend Selection.Style = ActiveDocument.Styles("Tabelltext") Selection.MoveRight Unit:=wdCharacter, Count:=4 Selection.MoveUp Unit:=wdLine, Count:=1 Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend Selection.MoveRight Unit:=wdCharacter, Count:=1 Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend Selection.Tables(1).Columns(3).SetWidth ColumnWidth:=115.3, RulerStyle:= _ wdAdjustNone Selection.MoveLeft Unit:=wdCharacter, Count:=3 Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend Selection.Tables(1).Rows.SetLeftIndent LeftIndent:=0.65, RulerStyle:= _ wdAdjustNone With Selection.Tables(1) .TopPadding = CentimetersToPoints(0) .BottomPadding = CentimetersToPoints(0) .LeftPadding = CentimetersToPoints(0.1) .RightPadding = CentimetersToPoints(0.1) .Spacing = 0 .AllowPageBreaks = True .AllowAutoFit = True End With Selection.Tables(1).Rows.LeftIndent = CentimetersToPoints(0.1) Selection.MoveDown Unit:=wdLine, Count:=2 Selection.MoveRight Unit:=wdCharacter, Count:=1 Selection.MoveUp Unit:=wdLine, Count:=2 Selection.MoveRight Unit:=wdCharacter, Count:=2 End Sub |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
macro table width (in Word)
You might see Jay Freedman's article on modifying recorded macros:
http://word.mvps.org/FAQs/MacrosVBA/...ordedMacro.htm Just an FYI: the plural of "thesis" is "theses," not "theseses." -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA "Lynn" wrote in message news I have a word formate template, used for theseses. It's based on an old format for theseses. In the template there are a few macros too. (I didn't create them). One of them is a table format macro, working fine. (Copied from the former template.) Problem is (in former and in new template) that tables are too wide. The left vertical line is too far out to the left (in the margin). (Since top and bottom lines are visible they stick out...) I've managed to record a macro of my own, same table format. While recording the macro it seems like I manage to change the width, but when running the macro it's too wide again. So probably I'm only changing that exact table, and not the macro itself. The code doesn't help me either. The old table macro is very simple, while the one I make myself contains every single move I make... so I can't even compare the code. (But since both tables are too wide it doesn't matter.) [And why is code so different...?] I'd really appreciate some help (code below). Lynn (not Lyn in thread). OLD CODE Selection.Tables(1).Select With Selection.Tables(1) .Borders(wdBorderLeft).LineStyle = wdLineStyleNone .Borders(wdBorderRight).LineStyle = wdLineStyleNone With .Borders(wdBorderTop) .LineStyle = wdLineStyleSingle .LineWidth = wdLineWidth050pt .ColorIndex = wdAuto End With With .Borders(wdBorderBottom) .LineStyle = wdLineStyleSingle .LineWidth = wdLineWidth050pt .ColorIndex = wdAuto End With .Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone .Borders(wdBorderVertical).LineStyle = wdLineStyleNone .Borders.Shadow = False End With With Options .DefaultBorderLineStyle = wdLineStyleSingle .DefaultBorderLineWidth = wdLineWidth050pt .DefaultBorderColorIndex = wdAuto End With Selection.Style = ActiveDocument.Styles("Tabelltext") End Sub NEW CODE (I also tried to add second horizontal line visible) ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=4, NumColumns:= _ 3, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _ wdAutoFitWindow With Selection.Tables(1) If .Style "Tabellrutnät" Then .Style = "Tabellrutnät" End If .ApplyStyleHeadingRows = True .ApplyStyleLastRow = True .ApplyStyleFirstColumn = True .ApplyStyleLastColumn = True End With Selection.MoveRight Unit:=wdCharacter, Count:=3, Extend:=wdExtend Selection.MoveLeft Unit:=wdCharacter, Count:=2, Extend:=wdExtend Selection.MoveRight Unit:=wdCharacter, Count:=2, Extend:=wdExtend Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend Selection.Borders(wdBorderTop).LineStyle = wdLineStyleNone Selection.Borders(wdBorderLeft).LineStyle = wdLineStyleNone Selection.Borders(wdBorderBottom).LineStyle = wdLineStyleNone Selection.Borders(wdBorderRight).LineStyle = wdLineStyleNone Selection.Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone Selection.Borders(wdBorderVertical).LineStyle = wdLineStyleNone Selection.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone Selection.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone Selection.MoveDown Unit:=wdLine, Count:=1 Selection.MoveUp Unit:=wdLine, Count:=1 Selection.MoveRight Unit:=wdCharacter, Count:=3, Extend:=wdExtend With Selection.Borders(wdBorderBottom) .LineStyle = Options.DefaultBorderLineStyle .LineWidth = Options.DefaultBorderLineWidth .Color = Options.DefaultBorderColor End With Selection.MoveUp Unit:=wdLine, Count:=3 Selection.MoveRight Unit:=wdCharacter, Count:=3, Extend:=wdExtend With Selection.Borders(wdBorderBottom) .LineStyle = Options.DefaultBorderLineStyle .LineWidth = Options.DefaultBorderLineWidth .Color = Options.DefaultBorderColor End With With Selection.Borders(wdBorderTop) .LineStyle = Options.DefaultBorderLineStyle .LineWidth = Options.DefaultBorderLineWidth .Color = Options.DefaultBorderColor End With Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend Selection.Style = ActiveDocument.Styles("Tabelltext") Selection.MoveRight Unit:=wdCharacter, Count:=4 Selection.MoveUp Unit:=wdLine, Count:=1 Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend Selection.MoveRight Unit:=wdCharacter, Count:=1 Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend Selection.Tables(1).Columns(3).SetWidth ColumnWidth:=115.3, RulerStyle:= _ wdAdjustNone Selection.MoveLeft Unit:=wdCharacter, Count:=3 Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend Selection.Tables(1).Rows.SetLeftIndent LeftIndent:=0.65, RulerStyle:= _ wdAdjustNone With Selection.Tables(1) .TopPadding = CentimetersToPoints(0) .BottomPadding = CentimetersToPoints(0) .LeftPadding = CentimetersToPoints(0.1) .RightPadding = CentimetersToPoints(0.1) .Spacing = 0 .AllowPageBreaks = True .AllowAutoFit = True End With Selection.Tables(1).Rows.LeftIndent = CentimetersToPoints(0.1) Selection.MoveDown Unit:=wdLine, Count:=2 Selection.MoveRight Unit:=wdCharacter, Count:=1 Selection.MoveUp Unit:=wdLine, Count:=2 Selection.MoveRight Unit:=wdCharacter, Count:=2 End Sub |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
macro table width (in Word)
Since you are planning to write a new macro, you might want to take the time
to create a table style (based on table grid) to set the grid lines, line weights, internal margins, and the table position (centered), etc. --But, to avoid conflicts with the paragraph styles and any manual formating you need, not fonts or column alignments.-- With the use of the table style, the meat of your macro could be just 4 lines long. Two to set the table width, one to set the paragraph style, and one to set the table style. "Lynn" wrote: I have a word formate template, used for theseses. It's based on an old format for theseses. In the template there are a few macros too. (I didn't create them). One of them is a table format macro, working fine. (Copied from the former template.) Problem is (in former and in new template) that tables are too wide. The left vertical line is too far out to the left (in the margin). (Since top and bottom lines are visible they stick out...) I've managed to record a macro of my own, same table format. While recording the macro it seems like I manage to change the width, but when running the macro it's too wide again. So probably I'm only changing that exact table, and not the macro itself. The code doesn't help me either. The old table macro is very simple, while the one I make myself contains every single move I make... so I can't even compare the code. (But since both tables are too wide it doesn't matter.) [And why is code so different...?] I'd really appreciate some help (code below). Lynn (not Lyn in thread). OLD CODE Selection.Tables(1).Select With Selection.Tables(1) .Borders(wdBorderLeft).LineStyle = wdLineStyleNone .Borders(wdBorderRight).LineStyle = wdLineStyleNone With .Borders(wdBorderTop) .LineStyle = wdLineStyleSingle .LineWidth = wdLineWidth050pt .ColorIndex = wdAuto End With With .Borders(wdBorderBottom) .LineStyle = wdLineStyleSingle .LineWidth = wdLineWidth050pt .ColorIndex = wdAuto End With .Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone .Borders(wdBorderVertical).LineStyle = wdLineStyleNone .Borders.Shadow = False End With With Options .DefaultBorderLineStyle = wdLineStyleSingle .DefaultBorderLineWidth = wdLineWidth050pt .DefaultBorderColorIndex = wdAuto End With Selection.Style = ActiveDocument.Styles("Tabelltext") End Sub NEW CODE (I also tried to add second horizontal line visible) ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=4, NumColumns:= _ 3, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _ wdAutoFitWindow With Selection.Tables(1) If .Style "Tabellrutnät" Then .Style = "Tabellrutnät" End If .ApplyStyleHeadingRows = True .ApplyStyleLastRow = True .ApplyStyleFirstColumn = True .ApplyStyleLastColumn = True End With Selection.MoveRight Unit:=wdCharacter, Count:=3, Extend:=wdExtend Selection.MoveLeft Unit:=wdCharacter, Count:=2, Extend:=wdExtend Selection.MoveRight Unit:=wdCharacter, Count:=2, Extend:=wdExtend Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend Selection.Borders(wdBorderTop).LineStyle = wdLineStyleNone Selection.Borders(wdBorderLeft).LineStyle = wdLineStyleNone Selection.Borders(wdBorderBottom).LineStyle = wdLineStyleNone Selection.Borders(wdBorderRight).LineStyle = wdLineStyleNone Selection.Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone Selection.Borders(wdBorderVertical).LineStyle = wdLineStyleNone Selection.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone Selection.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone Selection.MoveDown Unit:=wdLine, Count:=1 Selection.MoveUp Unit:=wdLine, Count:=1 Selection.MoveRight Unit:=wdCharacter, Count:=3, Extend:=wdExtend With Selection.Borders(wdBorderBottom) .LineStyle = Options.DefaultBorderLineStyle .LineWidth = Options.DefaultBorderLineWidth .Color = Options.DefaultBorderColor End With Selection.MoveUp Unit:=wdLine, Count:=3 Selection.MoveRight Unit:=wdCharacter, Count:=3, Extend:=wdExtend With Selection.Borders(wdBorderBottom) .LineStyle = Options.DefaultBorderLineStyle .LineWidth = Options.DefaultBorderLineWidth .Color = Options.DefaultBorderColor End With With Selection.Borders(wdBorderTop) .LineStyle = Options.DefaultBorderLineStyle .LineWidth = Options.DefaultBorderLineWidth .Color = Options.DefaultBorderColor End With Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend Selection.Style = ActiveDocument.Styles("Tabelltext") Selection.MoveRight Unit:=wdCharacter, Count:=4 Selection.MoveUp Unit:=wdLine, Count:=1 Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend Selection.MoveRight Unit:=wdCharacter, Count:=1 Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend Selection.Tables(1).Columns(3).SetWidth ColumnWidth:=115.3, RulerStyle:= _ wdAdjustNone Selection.MoveLeft Unit:=wdCharacter, Count:=3 Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend Selection.Tables(1).Rows.SetLeftIndent LeftIndent:=0.65, RulerStyle:= _ wdAdjustNone With Selection.Tables(1) .TopPadding = CentimetersToPoints(0) .BottomPadding = CentimetersToPoints(0) .LeftPadding = CentimetersToPoints(0.1) .RightPadding = CentimetersToPoints(0.1) .Spacing = 0 .AllowPageBreaks = True .AllowAutoFit = True End With Selection.Tables(1).Rows.LeftIndent = CentimetersToPoints(0.1) Selection.MoveDown Unit:=wdLine, Count:=2 Selection.MoveRight Unit:=wdCharacter, Count:=1 Selection.MoveUp Unit:=wdLine, Count:=2 Selection.MoveRight Unit:=wdCharacter, Count:=2 End Sub |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Column widths don't keep width set by macro | Tables | |||
setting the width for a picture in a macro | Microsoft Word Help | |||
why can't I set table column width in word? | Tables | |||
Reducing column width in a word table | Tables | |||
Changing column width in the Word table | Tables |