?
Solved

MS Word Macro Picture Help

Posted on 2009-05-19
1
Medium Priority
?
199 Views
Last Modified: 2012-05-07
Folks:

I need to play two graphic files at the top of my page.  This is to create a letter head using a macro.  The transcription department transcribes medical records, and we want to stop printing on letterhead.  I would like the graphics to be part of the Header, since I cut and past the body frequently for other purposes.

I have a start, but I cannot get the two images to be far left and far right respectively.  I want the LOGO to be far left (Farther than the margin, and the second graphic LH2.bmp to be far right.  This is the address portion saved as a graphic.

The macro then puts some text at the bottom.  

I just need a little help.  High points for speed.

Troyo

Sub LH1()
'
' LH1 Macro
' Macro recorded 5/19/2009 by overhotl
'
    If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
        ActiveWindow.Panes(2).Close
    End If
    If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
        ActivePane.View.Type = wdOutlineView Then
        ActiveWindow.ActivePane.View.Type = wdPrintView
    End If
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    Selection.InlineShapes.AddPicture FileName:= _
        "C:\Documents and Settings\overhotl\My Documents\LH1LOGO.PNG", LinkToFile _
        :=False, SaveWithDocument:=True
        Selection.PageSetup.RightMargin = InchesToPoints(0.25)
    With Selection.ParagraphFormat
        .LeftIndent = InchesToPoints(-1.5)
        .SpaceBeforeAuto = False
        .SpaceAfterAuto = False
    End With
    
    Selection.InlineShapes.AddPicture FileName:= _
        "C:\Documents and Settings\overhotl\My Documents\LH2.BMP", LinkToFile _
        :=False, SaveWithDocument:=True
        Selection.PageSetup.RightMargin = InchesToPoints(0.25)
    With Selection.ParagraphFormat
        .LeftIndent = InchesToPoints(5.5)
        .SpaceBeforeAuto = False
        .SpaceAfterAuto = False
    End With
    'Selection.TypeText Text:="                    "
    If Selection.HeaderFooter.IsHeader = True Then
        ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
    Else
        ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    End If
    Selection.TypeText Text:="Work Well Clinic" & vbTab & "Therapy Plus" & _
        vbTab & "Hearing Conservation"
    Selection.TypeParagraph
    Selection.TypeText Text:="(319) 369-8153" & vbTab & "(3190 369-8107" & _
        vbTab & "(319) 369-7569"
    Selection.MoveUp Unit:=wdLine, Count:=2, Extend:=wdExtend
    Selection.Font.Name = "Monotype Corsiva"
    Selection.Font.Size = 14
    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub

Open in new window

0
Comment
Question by:toverholt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 2000 total points
ID: 24427194
You need to insert  the pictures as Shapes if you want the flexibility to locate them in any position.
Sub LH2()
    Dim strPicture1 As String
    Dim strPicture2 As String
    Dim Doc As Document
    Dim hdr As HeaderFooter
    Dim ftr As HeaderFooter
    Dim sh1 As Shape
    Dim sh2 As Shape
    Dim hfix As WdHeaderFooterIndex
    
    strPicture1 = "C:\Documents and Settings\overhotl\My Documents\LH1LOGO.PNG"
    strPicture2 = "C:\Documents and Settings\overhotl\My Documents\LH2.BMP"
 
    Set Doc = ActiveDocument
    If Doc.Sections(1).PageSetup.DifferentFirstPageHeaderFooter Then
        hfix = wdHeaderFooterFirstPage
    Else
        hfix = wdHeaderFooterPrimary
    End If
    Set hdr = Doc.Sections(1).Headers(hfix)
    Set sh1 = Doc.Shapes.AddPicture(strPicture1, False, True, , , , , hdr.Range)
    sh1.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
    sh1.Left = 0
    Set sh2 = Doc.Shapes.AddPicture(strPicture1, False, True, , , , , hdr.Range)
    sh2.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
    sh2.Left = Doc.Sections(1).PageSetup.PageWidth - sh2.Width
    
    Set ftr = Doc.Sections(1).Footers(hfix)
    ftr.Range.Text = "Work Well Clinic" & vbTab & "Therapy Plus" & _
        vbTab & "Hearing Conservation" & vbCr & _
                "(319) 369-8153" & vbTab & "(3190 369-8107" & _
                vbTab & "(319) 369-7569"
        
    ftr.Range.Font.Name = "Monotype Corsiva"
    ftr.Range.Font.Size = 14
End Sub

Open in new window

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Authors who set out to write any sort of lengthy piece for online submission—be it a long question or comment on a technical form, an article, or a substantial blog entry—often find it useful to work up a draft in an editor other t…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question