Results 1 to 13 of 13
  1. #1
    Star Lounger
    Join Date
    Aug 2001
    Location
    Lebanon/France
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    thumbnail (2002)

    Hi
    I'm using excel sheets saved as html to display process drawings and jpeg pics of supporting documents on an intranet.
    I would like the user enabled to click a jpeg pic already pasted in view to enlarge it (as we do in websites with thumbnail pictures).
    I know a very little bit of VBA that I use recording macro and correcting/customizing the code afterwards
    That's mean I know nothing about click event syntax...
    question:
    Could you provide me with help in building a macro which would enlarge the size of a pic?
    In other words I try to duplicate in a VBA way the command Format>>Picture>>size and I would like to use this code in connection with a click on the pic...
    Thanks

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: thumbnail (2002)

    Hi Dominic,

    Something like this to enlarge:

    Sub BigPic()
    On Error Resume Next
    With Selection.ShapeRange
    .ScaleHeight 2.00, True
    .ScaleWidth 2.00, True
    End With
    End Sub

    or this to shrink:

    Sub LittlePic()
    On Error Resume Next
    With Selection.ShapeRange
    .ScaleHeight 0.25, True
    .ScaleWidth 0.25, True
    End With
    End Sub

    Note that you'd probably want to start with a full-size image and shrink it for the thumb-nail view, so as to mainatin resolution at the larger view.

    Cheers
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    Star Lounger
    Join Date
    Aug 2001
    Location
    Lebanon/France
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: thumbnail (2002)

    Thanks Macropod,

    This syntax is a lot clearer that the one I got recording the manual manipulation (which mentions specific picture size dimensions instead of percentage)

    The remaining problem is I would like to run this code on clicking the shape (and I confess I was more confused than helped by microsoft help)

  4. #4
    Star Lounger
    Join Date
    Aug 2001
    Location
    Lebanon/France
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: thumbnail (2002)

    As I do not know how to use it the click-event, I tried to work around it:
    I tused the command assign macro to the shape.
    Once I done that, the shape could not be selected anymore (the cursor displaying the"hand" hyperlink-sign).

    Then I thought that the macro "has to know" before running the downsizing/increasing if the shape is in its thumbnail aspect or full-size aspect...

    So my specific question is:
    How to run a click-event (or something similar) running either the code "squeeze the shape" if the picture is full-sized or the code "enlarge the shape" if the picture is (by default) displayed as thumbnail...?

    Does this make sense?

    Thanks

  5. #5
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: thumbnail (2002)

    Application.caller gives you the name of the shape that was clicked..
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  6. #6
    Star Lounger
    Join Date
    Aug 2001
    Location
    Lebanon/France
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: thumbnail (2002)

    "Application.caller gives you the name of the shape that was clicked".

    Sorry for beeing so ignorant but I dont understand how to use your information.
    Application.caller is totally unfamiliar to me.

    I looked for "caller" in VBA help.
    As far as I understood, the syntax of this property requires an expression, i.e.: {"expression".caller} and actually the example provided was: {application.caller}.
    Good start, I thought!
    But after reading the full example I still dont know:
    - neither how to use it (which index to add)
    - nor how to get (and use) the information related to the aspect of the shape (full size versus thumbnail) and moreover
    - how to launch the macro by clicking the shape...

    Help!

  7. #7
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: thumbnail (2002)

    Does something like this work? If the height is <100 it will reset the size to the original, otherwise it will reduce it to 25% of the original size. Assign this macro to any shape. Change the 0.25 to the desired "shrink factor" and change the <100 as needed

    Steve
    <pre>Sub ResizePic()
    Dim sPic As String
    Dim lFactor As Single
    sPic = Application.Caller
    ActiveSheet.Shapes(sPic).Select
    If Selection.Height < 100 Then
    lFactor = 1
    Else
    lFactor = 0.25
    End If
    With Selection.ShapeRange
    .ScaleHeight lFactor, True
    .ScaleWidth lFactor, True
    End With
    ActiveCell.Select
    End Sub
    </pre>


  8. #8
    Star Lounger
    Join Date
    Aug 2001
    Location
    Lebanon/France
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: thumbnail (2002)

    Waaooooooh!

    <img src=/S/bananas.gif border=0 alt=bananas width=33 height=35>*** I cant stop playing with it*** <img src=/S/bananas.gif border=0 alt=bananas width=33 height=35>
    Shrinking/Growing just clicking on it....

    Thousend thanks

    One, or more exactly two, arrr... three last questions:

    1 - what is the unit used in the line :
    Selection.Height < 100
    VBA help does not specify that in "height property"

    2 - How do I convert this unit (points?pixels?) in the one displayed by the command {format picture>>size} window (centimeters or inches)

    3 - I'm afraid that once the sheet is saved as html the macro cannot work. Did I miss something or {{ooops!}} did I bother everyone for an impossible task: enabeling the user browsing the html page in enlarging/shrinkintg he pic thanks to the macro????

  9. #9
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: thumbnail (2002)

    It should be in POINTS (1/72 of an inch). XL97 lists this in the Height Property.

    I don't work with XL in HTML, so I don't know what is and isn't possible. Hopefully someone else will chime in.

    Steve

  10. #10
    3 Star Lounger
    Join Date
    Jun 2001
    Location
    Maidstone, Kent, England
    Posts
    398
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: thumbnail (2002)

    I don't know how you would manipulate the picture itself in HTML but you could try the normal method of having a large picture available and hyperlink the thumbnail to it.

    I imagine that if you take a catalog's worth of full size pictures and embed them in to a HTML file as thumbnails it will take an age to load over the net!

    HTH

    Peter

  11. #11
    Star Lounger
    Join Date
    Aug 2001
    Location
    Lebanon/France
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: thumbnail (2002)

    Yes Peter, I agree, this is the best way.

    Despite the fact that this project is an intranet project (so not too much bandwith problem) the file with all the large pictures embedded is not a reasonable solution...

    Anyway I really appreciate all what I learned in this thread and thank everyone for the help. <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>

    As far as I tested, excel saved as webpage may keep a lot of interactivity such as adding/deleting sheets, navigating from sheet to sheet in a whole workbook, formating cells and creating formulas, playing with sorting, even autofilter... but macros are definitely lost. <img src=/S/groan.gif border=0 alt=groan width=16 height=15>

  12. #12
    3 Star Lounger
    Join Date
    Jun 2001
    Location
    Maidstone, Kent, England
    Posts
    398
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: thumbnail (2002)

    I am not sure that you can add a hyperlink to a picture directly but you can set the background of a normal rectangle to a picture and set a hyperlink to that.

    HTH

    Peter

  13. #13
    Star Lounger
    Join Date
    Aug 2001
    Location
    Lebanon/France
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: thumbnail (2002)

    Fortunately, when I right-click on my worksheet a pasted picture, the submenu window enables the hyperlink creation.
    Now my difficulties <img src=/S/brickwall.gif border=0 alt=brickwall width=25 height=15> are more about the web-html environment (for example adding an hyperlink on the picturefile called from the thumbnail in view to navigate from pic to pic) and I'm afraid they are out of the topic of my favorite excel board.

    Thanks Peter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •