PC Review


Reply
Thread Tools Rate Thread

assigning a variable from an image alt text

 
 
john.9.williams@openreach.co.uk
Guest
Posts: n/a
 
      9th Feb 2012
I have a program that i am developing. What happens is when i click on
an inserted image i want a certain text to be input into a cell.

No problem here, but i have around 40 images that when click the macro
puts different text into a cell. I do not want to write 40 different
macros so was thinking that if i assign the image with the text in
its alt.text property when i run the macro the alt text becomes the
variable

i.e

Sub test ()

DIM text

text = image alt text (code to go here)

range("a1") = text


not sure if this is possible or is there another way i am missing

many thanks
 
Reply With Quote
 
 
 
 
Tim Williams
Guest
Posts: n/a
 
      9th Feb 2012
Within your Test() sub, Application.Caller will give you the name of
the image which was clicked.

So you can get a reference to the image and its "alt text" using

ActiveSheet.Shapes(Application.Caller).AlternativeText

You might find it easier to create a lookup table (maybe on a hidden
sheet) which maps image names to the text you want to display. You
can then use vlookup() to do the mapping.

Tim


On Feb 9, 10:40*am, john.9.willi...@openreach.co.uk wrote:
> I have a program that i am developing. What happens is when i click on
> an inserted image i want a certain text to be input into a cell.
>
> No problem here, but i have around 40 images that when click the macro
> puts different text into a cell. *I do not want to write 40 different
> macros so was thinking that if i assign the image with the *text in
> its alt.text property when i run the macro the alt text becomes the
> variable
>
> i.e
>
> Sub test ()
>
> DIM text
>
> text = image alt text (code to go here)
>
> range("a1") = text
>
> not sure if this is possible or is there another way i am missing
>
> many thanks


 
Reply With Quote
 
john.9.williams@openreach.co.uk
Guest
Posts: n/a
 
      9th Feb 2012
On Feb 9, 6:51*pm, Tim Williams <timjwilli...@gmail.com> wrote:
> Within your Test() sub, Application.Caller will give you the name of
> the image which was clicked.
>
> So you can get a reference to the image and its "alt text" using
>
> ActiveSheet.Shapes(Application.Caller).AlternativeText
>
> You might find it easier to create a lookup table (maybe on a hidden
> sheet) which maps image names to the text you want to display. *You
> can then use vlookup() to do the mapping.
>
> Tim
>
> On Feb 9, 10:40*am, john.9.willi...@openreach.co.uk wrote:
>
>
>
> > I have a program that i am developing. What happens is when i click on
> > an inserted image i want a certain text to be input into a cell.

>
> > No problem here, but i have around 40 images that when click the macro
> > puts different text into a cell. *I do not want to write 40 different
> > macros so was thinking that if i assign the image with the *text in
> > its alt.text property when i run the macro the alt text becomes the
> > variable

>
> > i.e

>
> > Sub test ()

>
> > DIM text

>
> > text = image alt text (code to go here)

>
> > range("a1") = text

>
> > not sure if this is possible or is there another way i am missing

>
> > many thanks- Hide quoted text -

>
> - Show quoted text -


Hi Thanks, could you explain a little further my vb is not great, how
would i incorperate this into my sub()

many thanks
 
Reply With Quote
 
Tim Williams
Guest
Posts: n/a
 
      9th Feb 2012

Sub Test()

On Error Resume Next
With ActiveSheet
.Range("A1").value = .Shapes(Application.Caller).AlternativeText
On Error Goto 0

End Sub


On Feb 9, 11:08*am, john.9.willi...@openreach.co.uk wrote:
> On Feb 9, 6:51*pm, Tim Williams <timjwilli...@gmail.com> wrote:
>
>
>
>
>
> > Within your Test() sub, Application.Caller will give you the name of
> > the image which was clicked.

>
> > So you can get a reference to the image and its "alt text" using

>
> > ActiveSheet.Shapes(Application.Caller).AlternativeText

>
> > You might find it easier to create a lookup table (maybe on a hidden
> > sheet) which maps image names to the text you want to display. *You
> > can then use vlookup() to do the mapping.

>
> > Tim

>
> > On Feb 9, 10:40*am, john.9.willi...@openreach.co.uk wrote:

>
> > > I have a program that i am developing. What happens is when i click on
> > > an inserted image i want a certain text to be input into a cell.

>
> > > No problem here, but i have around 40 images that when click the macro
> > > puts different text into a cell. *I do not want to write 40 different
> > > macros so was thinking that if i assign the image with the *text in
> > > its alt.text property when i run the macro the alt text becomes the
> > > variable

>
> > > i.e

>
> > > Sub test ()

>
> > > DIM text

>
> > > text = image alt text (code to go here)

>
> > > range("a1") = text

>
> > > not sure if this is possible or is there another way i am missing

>
> > > many thanks- Hide quoted text -

>
> > - Show quoted text -

>
> Hi Thanks, could you explain a little further my vb is not great, how
> would i incorperate this into my sub()
>
> many thanks- Hide quoted text -
>
> - Show quoted text -


 
Reply With Quote
 
Tim Williams
Guest
Posts: n/a
 
      9th Feb 2012
Sub Test()


On Error Resume Next
With ActiveSheet
.Range("A1").value
= .Shapes(Application.Caller).AlternativeText
End With
On Error Goto 0


End Sub






On Feb 9, 11:08*am, john.9.willi...@openreach.co.uk wrote:
> On Feb 9, 6:51*pm, Tim Williams <timjwilli...@gmail.com> wrote:
>
>
>
>
>
> > Within your Test() sub, Application.Caller will give you the name of
> > the image which was clicked.

>
> > So you can get a reference to the image and its "alt text" using

>
> > ActiveSheet.Shapes(Application.Caller).AlternativeText

>
> > You might find it easier to create a lookup table (maybe on a hidden
> > sheet) which maps image names to the text you want to display. *You
> > can then use vlookup() to do the mapping.

>
> > Tim

>
> > On Feb 9, 10:40*am, john.9.willi...@openreach.co.uk wrote:

>
> > > I have a program that i am developing. What happens is when i click on
> > > an inserted image i want a certain text to be input into a cell.

>
> > > No problem here, but i have around 40 images that when click the macro
> > > puts different text into a cell. *I do not want to write 40 different
> > > macros so was thinking that if i assign the image with the *text in
> > > its alt.text property when i run the macro the alt text becomes the
> > > variable

>
> > > i.e

>
> > > Sub test ()

>
> > > DIM text

>
> > > text = image alt text (code to go here)

>
> > > range("a1") = text

>
> > > not sure if this is possible or is there another way i am missing

>
> > > many thanks- Hide quoted text -

>
> > - Show quoted text -

>
> Hi Thanks, could you explain a little further my vb is not great, how
> would i incorperate this into my sub()
>
> many thanks- Hide quoted text -
>
> - Show quoted text -


 
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



Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:05 PM.