Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
InserPictureInRange method for excel VBA
That works well, thanks a lot!
"Ron de Bruin" wrote: 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\PictureFile Name.gif") myPict.Top = .Top 'myPict.Width = .Width 'myPict.Height = .Height myPict.Left = .Left myPict.Placement = xlMoveAndSize End With End Sub -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "the excel-arator" <the wrote in message ... 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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Please post this thread a correct full method, method about | New Users to Excel | |||
Please post this thread a complete correct method, method about te | New Users to Excel | |||
GetObject method not work after Call Shell Method | Excel Programming | |||
Why QUIT method doesn't work after COPY method? | Excel Programming | |||
Excel OLE in VC++;AutoFormat Method | Excel Programming |