Thread: [Solved] Run a Macro in Word 2010
View Single Post
 
Old 04-29-2011, 03:27 PM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2000
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Joyce,

There's nothing in the code you posted that has anything to do with printing, per se. It's all about inserting one or two logos into the document header. If I've understood that code correctly, it could be simplified to:
Code:
Sub FormatTheFile()
Dim DocLogo As Document, DocMain As Document
Set DocMain = ActiveDocument
Set DocLogo = Documents.Open(FileName:=\\Lion\D$\CLIENTS\Authorization\LogoFile.doc, AddToRecentFiles:=False)
FileName$ = GetFileType$()
Select Case FileName$
  Case "IPWSM", "IPWSP", "IOPWSM"
    DocLogo.Shapes("Picture 5").Copy
    With DocMain.Sections(1).Headers(wdHeaderFooterPrimary).Range
      .Collapse wdCollapseStart
      .Paste
    End With
End Select
DocLogo.Shapes("Picture 6").Copy
With DocMain.Sections(1).Headers(wdHeaderFooterPrimary).Range
  .Collapse wdCollapseEnd
  .Paste
End With
DocLogo.Close SaveChanges:=False
FileName$ = GetFileType$()
Select Case FileName$
  Case "OICPIA", "OICPOA"
    Call OICPIA
  Case "IPSDP", "OPINTM", "IOPWSM", "IPHWP", "IOPWSPM", "IOPHEM", "IOPHEPM", "IOPHWPM", "IOPHWM"
    Selection.EndKey Unit:=wdStory
  Case Else
    'TEMP$ = MsgBox(FileName$ + ": UNKNOWN TYPE.", vbOKOnly, "Error")
End Select
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote