GrahamVincent
New Member
- Joined
- Mar 3, 2009
- Messages
- 5
Hi all
I have a macro that inserts an image into the header based on a variable held in a cell. (see below)
This works OK (if a little slowly) up to and including the RightHeader on the first worksheet (SH1).
However nothing is appearing in the header in the second sheet (SH2).
Am I missing something obvious?
Any help would be much appreciated
Feel free to critique, disect or chuckle
Sub InsertPicture()
Dim wb As Workbook
Dim SH1 As Worksheet
Dim SH2 As Worksheet
Dim vStr As String
Set wb = ThisWorkbook
Set SH1 = wb.Worksheets("Insurer")
Set SH2 = wb.Worksheets("Charts")
vStr = SH1.Range("T4").Text
With SH1.PageSetup.CenterHeaderPicture
.Filename = vStr
.Height = 200
.Width = 250
.Brightness = 0.36
.ColorType = msoPictureAutomatic
.Contrast = 0.39
.CropBottom = 0
.CropLeft = 0
.CropRight = 0
.CropTop = 0
End With
' Enable the image to show up in the left header.
ActiveSheet.PageSetup.CenterHeader = "&G"
With SH1.PageSetup.RightHeaderPicture
.Filename = "G:\MI\Insurer MI\New Suite Insurer Reports\TEST\LOGOS\MCDLogo.gif"
.Height = 45
.Width = 67.5
.Brightness = 0.36
.ColorType = msoPictureAutomatic
.Contrast = 0.39
.CropBottom = 0
.CropLeft = 0
.CropRight = 0
.CropTop = 0
End With
' Enable the image to show up in the left header.
ActiveSheet.PageSetup.RightHeader = "&G"
With SH2.PageSetup.CenterHeaderPicture
.Filename = vStr
.Height = 200
.Width = 250
.Brightness = 0.36
.ColorType = msoPictureAutomatic
.Contrast = 0.39
.CropBottom = 0
.CropLeft = 0
.CropRight = 0
.CropTop = 0
End With
' Enable the image to show up in the left header.
ActiveSheet.PageSetup.CenterHeader = "&G"
With SH2.PageSetup.RightHeaderPicture
.Filename = "G:\MI\Insurer MI\New Suite Insurer Reports\TEST\LOGOS\MCDLogo.gif"
.Height = 45
.Width = 67.5
.Brightness = 0.36
.ColorType = msoPictureAutomatic
.Contrast = 0.39
.CropBottom = 0
.CropLeft = 0
.CropRight = 0
.CropTop = 0
End With
' Enable the image to show up in the left header.
ActiveSheet.PageSetup.RightHeader = "&G"
End Sub
I have a macro that inserts an image into the header based on a variable held in a cell. (see below)
This works OK (if a little slowly) up to and including the RightHeader on the first worksheet (SH1).
However nothing is appearing in the header in the second sheet (SH2).
Am I missing something obvious?
Any help would be much appreciated
Feel free to critique, disect or chuckle
Sub InsertPicture()
Dim wb As Workbook
Dim SH1 As Worksheet
Dim SH2 As Worksheet
Dim vStr As String
Set wb = ThisWorkbook
Set SH1 = wb.Worksheets("Insurer")
Set SH2 = wb.Worksheets("Charts")
vStr = SH1.Range("T4").Text
With SH1.PageSetup.CenterHeaderPicture
.Filename = vStr
.Height = 200
.Width = 250
.Brightness = 0.36
.ColorType = msoPictureAutomatic
.Contrast = 0.39
.CropBottom = 0
.CropLeft = 0
.CropRight = 0
.CropTop = 0
End With
' Enable the image to show up in the left header.
ActiveSheet.PageSetup.CenterHeader = "&G"
With SH1.PageSetup.RightHeaderPicture
.Filename = "G:\MI\Insurer MI\New Suite Insurer Reports\TEST\LOGOS\MCDLogo.gif"
.Height = 45
.Width = 67.5
.Brightness = 0.36
.ColorType = msoPictureAutomatic
.Contrast = 0.39
.CropBottom = 0
.CropLeft = 0
.CropRight = 0
.CropTop = 0
End With
' Enable the image to show up in the left header.
ActiveSheet.PageSetup.RightHeader = "&G"
With SH2.PageSetup.CenterHeaderPicture
.Filename = vStr
.Height = 200
.Width = 250
.Brightness = 0.36
.ColorType = msoPictureAutomatic
.Contrast = 0.39
.CropBottom = 0
.CropLeft = 0
.CropRight = 0
.CropTop = 0
End With
' Enable the image to show up in the left header.
ActiveSheet.PageSetup.CenterHeader = "&G"
With SH2.PageSetup.RightHeaderPicture
.Filename = "G:\MI\Insurer MI\New Suite Insurer Reports\TEST\LOGOS\MCDLogo.gif"
.Height = 45
.Width = 67.5
.Brightness = 0.36
.ColorType = msoPictureAutomatic
.Contrast = 0.39
.CropBottom = 0
.CropLeft = 0
.CropRight = 0
.CropTop = 0
End With
' Enable the image to show up in the left header.
ActiveSheet.PageSetup.RightHeader = "&G"
End Sub