This is the current code I'm running. I'm also having trouble removing a space at the top of the image. The image should be exactly the same size as the sheet so everything is shifted down. I still want the header to continue on the next page if the image
isn't on that page.
Thanks again for your help!
Sub AddImageObject()
Dim f As String
Dim d As Object
Dim p As Boolean
Dim i As Long
Dim j As Long
Dim k As Long
k = Selection.Information(wdActiveEndSectionNumber)
Set d = Application.FileDialog(msoFileDialogFilePicker)
With d
.AllowMultiSelect = False
.Title = "Please pick the file to insert."
.Filters.Clear
.Filters.Add "Image", "*.png"
.Filters.Add "Image", "*.jpg"
p = False
p = .Show
If p Then f = .SelectedItems.Item(1)
End With
'section break to stop using the header/footer formating
Selection.InsertBreak 2
ActiveDocument.Sections(k + 1).Headers(wdHeaderFooterPrimary).LinkToPrevious = False
Selection.InsertBreak 3
Selection.Sections(1).Headers(wdHeaderFooterPrimary).LinkToPrevious = False
Selection.Move wdSection, -1
Selection.Sections(1).Headers(wdHeaderFooterPrimary).Range.Delete
'format the page to maximum window for the pdf of the same sheet size to be full size
With Selection.ParagraphFormat
.LeftIndent = InchesToPoints(0)
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
End With
With ActiveDocument.Sections(k + 1)
.PageSetup.BottomMargin = InchesToPoints(0)
.PageSetup.RightMargin = InchesToPoints(0)
.PageSetup.LeftMargin = InchesToPoints(0)
.PageSetup.Gutter = InchesToPoints(0)
.PageSetup.HeaderDistance = InchesToPoints(0)
.PageSetup.FooterDistance = InchesToPoints(0)
.PageSetup.TopMargin = InchesToPoints(0)
End With
Selection.InlineShapes.AddPicture FileName:=f, LinkToFile:=False, SaveWithDocument:=True
End Sub