Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading Gif images in Excel with V.B.A

Status
Not open for further replies.

davefish

Technical User
Jul 26, 2002
169
GB
I am trying to manipulate a number of tranparent GIF's in an Excel Speadsheet to derive a single drawing. I can load these to a User Form element, but cannot seems to load them to the sheet. Can anyone point me in the right direction.

DF
 
Hi,

Try turning on your macro recorder and recording the process for Inserting an Picture into your Sheet.

View the code and modify to suite. Post back if you have problems :)

Skip,
Skip@TheOfficeExperts.com
 
DF,

The following is an example of manipulting images in Excel.

Sheet1.Image10.Picture = LoadPicture("C:\Program Files\Microsoft Visual Studio\Common\Graphics\Icons\Misc\face01.ico")

Hope this helps.

Leigh Moore
LJM Analysis Ltd
 
Just something to get you started!

Code:
Sub Macro1()
Dim Gif As Object
Set Gif = ActiveSheet.Pictures.Insert( _
        "C:\My Documents\My Pictures\MyGIF.gif")
With Gif.ShapeRange
    .IncrementLeft -33#
    .IncrementTop 15.75
End With
End Sub

I hope this helps!

Peace! [peace]

Mike

Never say Never!!!
Nothing is impossible!!!
 
HI Leigh,

Thanks for the tip. My main roblem is I wish to specify where the picture ends up on the page, hopefully using X,Y coordinates. Am I expecting too much?

Dave
 
Dave,

The image should have a Top and a Left property value, usually in Twipps so you could use...

Dim x As Integer
Dim y As Integer

x = ???
y = ???

Sheet1.Image10.Top = x
Sheet1.Image10.Left = y

Hope this helps.


Leigh Moore
LJM Analysis Ltd
 
You could actually just use this:
Code:
Sub InsertGif()
ActiveSheet.Pictures.Insert ("C:\My Documents\My Pictures\MyGIF.gif")
End Sub
[code]

and the picture will be inserted in the Activecell.

OR
[code]Sub InsertGif()
[D15].Activate
ActiveSheet.Pictures.Insert ("C:\My Documents\My Pictures\MyGIF.gif")
End Sub

Will insert it at D15 on the ActiveSheet. The upper left corner of the GIF will be slightly below and to the right of the upper left corner of the cell though.

Good Luck!


Peace! [peace]

Mike

Never say Never!!!
Nothing is impossible!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top