PC Review


Reply
Thread Tools Rate Thread

Change jpeg Picture in LeftHeader

 
 
Ryan H
Guest
Posts: n/a
 
      8th Dec 2009
I have two option buttons on a sheet called "QUOTE". Each option button
represents a company. When their option button is selected I want there logo
to be in the header. How can I change the logo jpeg in the header using code
like I have below? I'm getting an error where objLogo is in all of the code.

Sub HeaderFooterChanger()

Dim objLogo As Variant
Dim strRightHeader As String
Dim strCenterFooter As String

Application.ScreenUpdating = False

With Sheets("QUOTE")

' which option button is true
' Constants Enumeration: xlOn = 1 and xlOff = -4146
Select Case xlOn

' Ad Tech
Case .OptionButtons("optAdTech").Value

objLogo = .PageSetup.LeftHeaderPicture = _
"\\cdc.gov\private\M131\iqz9\Ad Tech\Formetco Logo.jpg"

strRightHeader = "&""-,Bold""QUOTATION / SALES AGREEMENT" &
Chr(10) & _
"&""-,Regular""Ad-Tech International, Inc."
& Chr(10) & _
"2963 Pleasant Hill Road" & Chr(10) & _
"Duluth, GA 30096" & Chr(10) & _
"PH 770-209-9102, Fax 770-209-0465" &
Chr(10) & _
"&D"
strCenterFooter = "Ad-Tech International, Inc." & Chr(10) & _
"www.adtechintl.com"

' Formetco
Case .OptionButtons("optFormetco").Value

objLogo = .PageSetup.LeftHeaderPicture = _
"\\cdc.gov\private\M131\iqz9\Ad Tech\Formetco Logo.jpg"

strRightHeader = "&""-,Bold""QUOTATION / SALES AGREEMENT" &
Chr(10) & _
"&""-,Regular""Formetco" & Chr(10) & _
"2963 Pleasant Hill Road" & Chr(10) & _
"Duluth, GA 30096" & Chr(10) & _
"PH 1-800-Formetco, Fax ???-???-????" &
Chr(10) & _
"&D"
strCenterFooter = "Formetco" & Chr(10) & _
"www.formetco.com"
End Select

' change header/footer properties
With .PageSetup

' change logo
.LeftHeaderPicture = objLogo

' ensure header picture can be visible
.LeftHeader = "&G"

' change header/footer
.RightHeader = strRightHeader
.CenterFooter = strCenterFooter
End With
End With

Application.ScreenUpdating = True

End Sub
--
Cheers,
Ryan
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      8th Dec 2009
First, try recording a macro when you change the picture in the header.

You'll see code like:

.PageSetup.RightHeaderPicture.Filename = "C:\folder\picture.jpg"

objLogo = .PageSetup.LeftHeaderPicture = _
"\\cdc.gov\private\M131\iqz9\Ad Tech\Formetco Logo.jpg"

So you could drop the objLogo variable completely:

..PageSetup.LeftHeaderPicture.FileName = _
"\\cdc.gov\private\M131\iqz9\Ad Tech\Formetco Logo.jpg"

and
..PageSetup.LeftHeaderPicture.filename = _
"\\cdc.gov\private\M131\iqz9\Ad Tech\Formetco Logo.jpg"

Or you could use a string variable do the work:

dim strLogo as string
...lots of code
strlogo = "\\cdc.gov\private\M131\iqz9\Ad Tech\Formetco Logo.jpg"
.pagesetup.leftheaderpicture.filename = strlogo



Ryan H wrote:
>
> I have two option buttons on a sheet called "QUOTE". Each option button
> represents a company. When their option button is selected I want there logo
> to be in the header. How can I change the logo jpeg in the header using code
> like I have below? I'm getting an error where objLogo is in all of the code.
>
> Sub HeaderFooterChanger()
>
> Dim objLogo As Variant
> Dim strRightHeader As String
> Dim strCenterFooter As String
>
> Application.ScreenUpdating = False
>
> With Sheets("QUOTE")
>
> ' which option button is true
> ' Constants Enumeration: xlOn = 1 and xlOff = -4146
> Select Case xlOn
>
> ' Ad Tech
> Case .OptionButtons("optAdTech").Value
>
> objLogo = .PageSetup.LeftHeaderPicture = _
> "\\cdc.gov\private\M131\iqz9\Ad Tech\Formetco Logo.jpg"
>
> strRightHeader = "&""-,Bold""QUOTATION / SALES AGREEMENT" &
> Chr(10) & _
> "&""-,Regular""Ad-Tech International, Inc."
> & Chr(10) & _
> "2963 Pleasant Hill Road" & Chr(10) & _
> "Duluth, GA 30096" & Chr(10) & _
> "PH 770-209-9102, Fax 770-209-0465" &
> Chr(10) & _
> "&D"
> strCenterFooter = "Ad-Tech International, Inc." & Chr(10) & _
> "www.adtechintl.com"
>
> ' Formetco
> Case .OptionButtons("optFormetco").Value
>
> objLogo = .PageSetup.LeftHeaderPicture = _
> "\\cdc.gov\private\M131\iqz9\Ad Tech\Formetco Logo.jpg"
>
> strRightHeader = "&""-,Bold""QUOTATION / SALES AGREEMENT" &
> Chr(10) & _
> "&""-,Regular""Formetco" & Chr(10) & _
> "2963 Pleasant Hill Road" & Chr(10) & _
> "Duluth, GA 30096" & Chr(10) & _
> "PH 1-800-Formetco, Fax ???-???-????" &
> Chr(10) & _
> "&D"
> strCenterFooter = "Formetco" & Chr(10) & _
> "www.formetco.com"
> End Select
>
> ' change header/footer properties
> With .PageSetup
>
> ' change logo
> .LeftHeaderPicture = objLogo
>
> ' ensure header picture can be visible
> .LeftHeader = "&G"
>
> ' change header/footer
> .RightHeader = strRightHeader
> .CenterFooter = strCenterFooter
> End With
> End With
>
> Application.ScreenUpdating = True
>
> End Sub
> --
> Cheers,
> Ryan


--

Dave Peterson
 
Reply With Quote
 
Gary Keramidas
Guest
Posts: n/a
 
      8th Dec 2009
you could use a boolean variable that sets it to true for one button and false
for the other. although in your code it looks like they're the same pic. maybe
i'm missing something.

if comp = true then
objLogo = .PageSetup.LeftHeaderPicture = _
"\\cdc.gov\private\M131\iqz9\Ad Tech\Formetco Logo.jpg"
else
objLogo = .PageSetup.LeftHeaderPicture = _
"\\cdc.gov\private\M131\iqz9\Ad Tech\Formetco Logo.jpg"
end if

.LeftHeaderPicture = objLogo


--


Gary Keramidas
Excel 2003


"Ryan H" <(E-Mail Removed)> wrote in message
news:B2675EC8-2483-44EE-9537-(E-Mail Removed)...
>I have two option buttons on a sheet called "QUOTE". Each option button
> represents a company. When their option button is selected I want there logo
> to be in the header. How can I change the logo jpeg in the header using code
> like I have below? I'm getting an error where objLogo is in all of the code.
>
> Sub HeaderFooterChanger()
>
> Dim objLogo As Variant
> Dim strRightHeader As String
> Dim strCenterFooter As String
>
> Application.ScreenUpdating = False
>
> With Sheets("QUOTE")
>
> ' which option button is true
> ' Constants Enumeration: xlOn = 1 and xlOff = -4146
> Select Case xlOn
>
> ' Ad Tech
> Case .OptionButtons("optAdTech").Value
>
> objLogo = .PageSetup.LeftHeaderPicture = _
> "\\cdc.gov\private\M131\iqz9\Ad Tech\Formetco Logo.jpg"
>
> strRightHeader = "&""-,Bold""QUOTATION / SALES AGREEMENT" &
> Chr(10) & _
> "&""-,Regular""Ad-Tech International, Inc."
> & Chr(10) & _
> "2963 Pleasant Hill Road" & Chr(10) & _
> "Duluth, GA 30096" & Chr(10) & _
> "PH 770-209-9102, Fax 770-209-0465" &
> Chr(10) & _
> "&D"
> strCenterFooter = "Ad-Tech International, Inc." & Chr(10) & _
> "www.adtechintl.com"
>
> ' Formetco
> Case .OptionButtons("optFormetco").Value
>
> objLogo = .PageSetup.LeftHeaderPicture = _
> "\\cdc.gov\private\M131\iqz9\Ad Tech\Formetco Logo.jpg"
>
> strRightHeader = "&""-,Bold""QUOTATION / SALES AGREEMENT" &
> Chr(10) & _
> "&""-,Regular""Formetco" & Chr(10) & _
> "2963 Pleasant Hill Road" & Chr(10) & _
> "Duluth, GA 30096" & Chr(10) & _
> "PH 1-800-Formetco, Fax ???-???-????" &
> Chr(10) & _
> "&D"
> strCenterFooter = "Formetco" & Chr(10) & _
> "www.formetco.com"
> End Select
>
> ' change header/footer properties
> With .PageSetup
>
> ' change logo
> .LeftHeaderPicture = objLogo
>
> ' ensure header picture can be visible
> .LeftHeader = "&G"
>
> ' change header/footer
> .RightHeader = strRightHeader
> .CenterFooter = strCenterFooter
> End With
> End With
>
> Application.ScreenUpdating = True
>
> End Sub
> --
> Cheers,
> Ryan


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i change a picture to a jpeg format JennyR Microsoft Word New Users 2 21st Dec 2008 05:52 PM
change type of file picture is JPEG to JPG? studente Microsoft Word Document Management 1 11th Apr 2008 06:12 PM
how do I overlay a clip picture on a Jpeg picture =?Utf-8?B?Q2F0aHk=?= Microsoft Access 1 13th Nov 2006 04:33 PM
how do I overlay a clip picture on a Jpeg picture =?Utf-8?B?Q2F0aHk=?= Microsoft Access 1 13th Nov 2006 04:29 PM
Using jpeg picture =?Utf-8?B?TXVyaWVs?= Microsoft Powerpoint 1 14th Oct 2004 07:12 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:21 AM.