Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default InserPictureInRange method for excel VBA

I found a snippit of code on an excel help website which is supposed to
insert a picture into a range of cells. However, when the code is run, I get
a compile error saying the sub or function is not defined. Should the code
below work? And if not, does anyone have any ideas on how to insert a picture
into a specified range of cells? The only way I know of is the "addpicture"
method where you have to specify in points where the image is insert, and how
large to make the image.
Using cell references for sizing and placement would be alot easier! I'm new
to VBA, so simplified explanations would be appreciated!

Here's the code I found:

Sub TestInsertPictureInRange()
InsertPictureInRange "C:\FolderName\PictureFileName.gif", _
Range("B5:D10")
End Sub

Thanks for you help!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default InserPictureInRange method for excel VBA

ActiveSheet.Shapes.AddPicture
"http://www.google.com/intl/en_ALL/images/logo.gif", msoTrue, msoFalse, 0, 0,
10, 10

I used to use that to link images (not embed) in Excel 2003 spreadsheets. In
Excel 2003 you could use AddPicture and a URL in place of a local image
filename, and you could enable and disable linking and embedding. That
prevented your workbook from choking on embedded images.

With the advent of Excel 2007 AddPicture no longer accepts URLs in place of
local image file names. See:

http://support.microsoft.com/kb/928983/en-us

Now I use the following code, which does not allow for enabling linking and
disabling embedding, that I am awa

Dim MyPicture As Shape
Set MyPicture = ActiveSheet.Shapes.AddShape(msoShapeRectangle, 0, 0, 10, 10)
MyPicture.Fill.UserPicture "http://www.google.com/intl/en_ALL/images/logo.gif"

UserPicture can accept a URL in place of a local image file name, but I
haven't figured out how to enable linking and disable embedding when using
UserPicture.

Can anyone suggest a way to insert an image from either a local file name or
a URL and still enable linking and disable embedding?

Thanks for your help.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default InserPictureInRange method for excel VBA

Thank you - I was looking for that code :)

This is not a standard function of Excel

You can also use this

Sub Test()
Dim myPict As Picture
With ActiveSheet.Range("B5")
Set myPict = .Parent.Pictures.Insert("C:\FolderName
\PictureFileName.gif")
myPict.Top = .Top
'myPict.Width = .Width
'myPict.Height = .Height
myPict.Left = .Left
myPict.Placement = xlMoveAndSize
End With
End Sub
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please post this thread a correct full method, method about Nast Runsome New Users to Excel 8 February 25th 08 03:29 PM
Please post this thread a complete correct method, method about te Nast Runsome New Users to Excel 0 February 23rd 08 09:42 PM
GetObject method not work after Call Shell Method ben Excel Programming 8 February 21st 06 03:45 PM
Why QUIT method doesn't work after COPY method? surotkin Excel Programming 3 October 26th 05 04:32 PM
Excel OLE in VC++;AutoFormat Method Debabrata Excel Programming 0 September 23rd 05 01:16 PM


All times are GMT +1. The time now is 10:53 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"