Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
insert a line in a macro
I am trying to insert a line into a header through a macro but the line wont
appear. The line button seems to work but the line wont draw. I have found reference that inserting files or pictures wont work, can someone tell me otherwise? I have tried inserting a line first and then selecting it once in macro mode which works and then i can draw another line. Hower when I run the macro it then has a bug as it is unable to find the correct line which is fair enough. Thanks -- Hayley |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
insert a line in a macro
There's no way to comment on your macro without seeing the code.
Perhaps a simpler method for you would be to draw the line manually and define it as an autotext entry; then use the macro to insert the autotext entry. "Hayley" wrote in message ... I am trying to insert a line into a header through a macro but the line wont appear. The line button seems to work but the line wont draw. I have found reference that inserting files or pictures wont work, can someone tell me otherwise? I have tried inserting a line first and then selecting it once in macro mode which works and then i can draw another line. Hower when I run the macro it then has a bug as it is unable to find the correct line which is fair enough. Thanks -- Hayley |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
insert a line in a macro
You may have to add some text to the header in order to see the
border(s). Something like this: With ActiveDocument.Sections(1) _ .Headers(wdHeaderFooterPrimary).Range With .Borders(wdBorderBottom) .Visible = True .LineStyle = wdLineStyleDot .LineWidth = wdLineWidth100pt End With .InsertAfter "Some header text" End With Of course, if you are using a different first page and/or different odd and even headers, matters will be more complex. It would be easier to add one or more border to the Header paragraph style: With ActiveDocument.Styles(wdStyleHeader) With .Borders(wdBorderBottom) .Visible = True .LineStyle = wdLineStyleDot .LineWidth = wdLineWidth100pt End With End With But, again, the border won't be visible unless the header has contents. -- Stefan Blom Microsoft Word MVP "Hayley" wrote in message ... I am trying to insert a line into a header through a macro but the line wont appear. The line button seems to work but the line wont draw. I have found reference that inserting files or pictures wont work, can someone tell me otherwise? I have tried inserting a line first and then selecting it once in macro mode which works and then i can draw another line. Hower when I run the macro it then has a bug as it is unable to find the correct line which is fair enough. Thanks -- Hayley |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
insert a line in a macro
Hi Hayley,
I am trying to insert a line into a header through a macro but the line wont appear. The line button seems to work but the line wont draw. I have found reference that inserting files or pictures wont work, can someone tell me otherwise? Hmm, yes, this would be one of the more difficult things for the macro recorder. Here's a bit of macro code that inserts a line one inch from the top, the full width of the page between the margins. The line weight is set, and the line is then colored red. It looks a bit complicated because I wanted to make sure the macro code would (I hope) fit to avoid unexpected line breaks that could cause error messages. Sub LineIntoHeader() Dim rng As Word.Range Dim hf As Word.HeaderFooter Dim sec As Word.Section Dim shp As Word.Shape Dim pgSetup As Word.PageSetup Dim LineLength As Single Set sec = Selection.Sections(1) Set hf = sec.Headers(wdHeaderFooterPrimary) Set pgSetup = sec.PageSetup Set rng = hf.Range LineLength = pgSetup.PageWidth - pgSetup.LeftMargin _ - pgSetup.RightMargin Set shp = hf.Shapes.AddLine( _ BeginX:=InchesToPoints(0), _ BeginY:=InchesToPoints(1), _ EndX:=LineLength, _ EndY:=InchesToPoints(1), Anchor:=rng) shp.Line.Weight = 1.5 shp.Line.ForeColor.RGB = RGB(255, 0, 0) End Sub I have tried inserting a line first and then selecting it once in macro mode which works and then i can draw another line. Hower when I run the macro it then has a bug as it is unable to find the correct line which is fair enough. Cindy Meister INTER-Solutions, Switzerland http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005) http://www.word.mvps.org This reply is posted in the Newsgroup; please post any follow question or reply in the newsgroup and not by e-mail :-) |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
double window envelope | Page Layout | |||
how to insert a solid line for signatures, dates | Microsoft Word Help | |||
Macro execution using MailMerge | Mailmerge | |||
Line Wrap Macro - How To Do It? | Microsoft Word Help | |||
Trying to create word macro to insert into SQL Server | New Users |