Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Hayley Hayley is offline
external usenet poster
 
Posts: 6
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Jezebel Jezebel is offline
external usenet poster
 
Posts: 1,384
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Stefan Blom Stefan Blom is offline
external usenet poster
 
Posts: 8,428
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Cindy M -WordMVP- Cindy M  -WordMVP- is offline
external usenet poster
 
Posts: 370
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
double window envelope tpdebronsky Page Layout 5 May 18th 23 08:51 PM
how to insert a solid line for signatures, dates Marie Microsoft Word Help 3 April 21st 23 12:59 PM
Macro execution using MailMerge nelsonj Mailmerge 9 June 13th 06 05:04 PM
Line Wrap Macro - How To Do It? ConfusedNHouston Microsoft Word Help 2 July 30th 05 05:53 AM
Trying to create word macro to insert into SQL Server Ian Clark New Users 1 March 15th 05 05:01 PM


All times are GMT +1. The time now is 11:51 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"