MSGBOX/Radio Button to select logo

L

LB79

I have a report template that is used for several different brands of my
company. When i use the template i want a MSGBOX to open up and list 3
buttons - 1 for each brand. When a button/brand is selected it will
choose the relevent logo and add it to the report.

If possible the logo will only appear on the print out and not on the
screen.

Can anyone help me with this of is there an alternitive?

Many thanks
 
D

Dave Peterson

Maybe you could just have a macro that shows/prints/hides depending on the
choice of the user.

You could build a userform that looks pretty or use something like this. I put
3 pictures on a worksheet (picture 1, picture 2 and picture 3). Change the
names to match your pictures and change the prompt to make more sense (company
names?):

Option Explicit
Sub testme()

Dim Ans As Variant
Dim myPictName As String

Ans = InputBox(prompt:="1 = picture 1" & _
vbLf & "2 = picture 2" & _
vbLf & "3 = picture 3")

With Worksheets("sheet1")
'hide them all
.Pictures("picture 1").Visible = False
.Pictures("picture 2").Visible = False
.Pictures("picture 3").Visible = False

'show the one you want
myPictName = ""
Select Case Trim(Ans)
Case Is = "1": myPictName = "picture 1"
Case Is = "2": myPictName = "picture 2"
Case Is = "3": myPictName = "picture 3"
Case Else
MsgBox "Try again later"
Exit Sub
End Select


.Pictures(myPictName).Visible = True
.PrintOut preview:=True
.Pictures(myPictName).Visible = False
End With

End Sub
 
D

daniel chen

Hi Dave,
How do I put pictures on a worksheet.
I can put bitmap on a worksheet, but not able to name it.
Thanks
 
D

Dave Peterson

After you put the picture on the worksheet (I use the "Insert Picture from File"
icon on the drawing toolbar), you can select it (sometimes rightclicking on it
is easier).

But after you select it, you can type the new name of the picture in the namebox
(to the left of the formulabar). Remember to hit enter after you type the new
name.

(You can use "Insert|Picture|from file" from the worksheet menubar, too.)

daniel said:
Hi Dave,
How do I put pictures on a worksheet.
I can put bitmap on a worksheet, but not able to name it.
Thanks
 
D

daniel chen

Upon executing the "Testme" macro,
MsgBox said "Uable to get the Pictures property of the Worksheet class"
Debug line @ .Pictures("picture 1").Visible = False
What am I doing wrong? Please, I am trying to learn.
 
D

Dave Peterson

Do you have a picture on sheet1 that's named "Picture 1"?

Select the picture and look at the namebox -- to the left of the formulabar.



daniel said:
Upon executing the "Testme" macro,
MsgBox said "Uable to get the Pictures property of the Worksheet class"
Debug line @ .Pictures("picture 1").Visible = False
What am I doing wrong? Please, I am trying to learn.
 
D

daniel chen

Yes, I was able to put 3 pictures in sheet1. I saw the names for each
picture in the namebox,
but those names were not the same as I tried to name them. They were
assigned by the computer as pictures 26,
picture 27 and picture 28. I don't know how to rename them. So, I changed
the names in the macro to reflect
them. Now, I see how your macro works.
I can only click on the picture, then Insert | Name | Define where I give
a name to refer to that picture #.
Is that how it works? Thanks for your patience.
 
D

Dave Peterson

When the picture is selected, you can type the name in the namebox to the left
of the formulabar--not the insert|name|define dialog.

You could use a macro that does something like:

with activesheet
.pictures("Picture 26").name = "MyNewName"
end with



daniel said:
Yes, I was able to put 3 pictures in sheet1. I saw the names for each
picture in the namebox,
but those names were not the same as I tried to name them. They were
assigned by the computer as pictures 26,
picture 27 and picture 28. I don't know how to rename them. So, I changed
the names in the macro to reflect
them. Now, I see how your macro works.
I can only click on the picture, then Insert | Name | Define where I give
a name to refer to that picture #.
Is that how it works? Thanks for your patience.
 
D

daniel chen

Hi Dave,
Yes, I got it.
Thank you very much.

Dave Peterson said:
When the picture is selected, you can type the name in the namebox to the left
of the formulabar--not the insert|name|define dialog.

You could use a macro that does something like:

with activesheet
.pictures("Picture 26").name = "MyNewName"
end with
 
Top