473,411 Members | 1,991 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Insert a picture in specific cells in Excel

Hi Everyone!

I tried to insert a picture in specific cells and I have coded a small VBA for Excel 2007. Unfortunately the macro only opens and inserts a picture in the active sheet but it should add the picture in cell B3, H4 and L6 in this sheet.

Could you please help me to fix the problem.

thx a lot!

Expand|Select|Wrap|Line Numbers
  1.  
  2. Sub Macro1()
  3.  
  4. Dim Pict
  5. Dim ImgFileFormat As String
  6. Dim PictCell As Range
  7. Dim Ans As Integer
  8.  
  9. ImgFileFormat = "Image Files (*.bmp),others, tif (*.tif),*.tif, jpg (*.jpg),*.jpg"
  10.  
  11. GetPict:
  12. Pict = Application.GetOpenFilename(ImgFileFormat)
  13. If Pict = False Then End
  14.  
  15. ActiveSheet.Pictures.Insert(Pict).Select
  16.  
  17. End Sub
  18.  
  19.  
Oct 20 '09 #1
4 21240
Dököll
2,364 Expert 2GB
Sending over to Access forum for a closer look; have you tried searching beforehand, might have been something posted on this, give that a try while you wait if need be.

In a bit, good luck!
Nov 9 '09 #2
Delerna
1,134 Expert 1GB
Here is the code I got
Expand|Select|Wrap|Line Numbers
  1. Sub Macro1()
  2. '
  3. ' Macro1 Macro
  4. ' Macro recorded 9/11/2009 by Graham
  5. '
  6.  
  7. '
  8.     Range("G13").Select
  9.     ActiveSheet.Pictures.Insert( _
  10.         "C:\Documents and Settings\Graham\My Documents\My Pictures\barb3.png").Select
  11. End Sub
  12.  
HINT
I always find that if I am usure how to do something using VBA within Word or excel, then

1) record a new macro
2) perform the steps that I want my code to do
3) stop recording the macro
4) Go check the code the macro recorder generated and adjust it to suit my needs
Nov 9 '09 #3
MMcCarthy
14,534 Expert Mod 8TB
OK the short answer to your question is you can't insert a picture into a specific cell in Excel. There is a facility to add a background image to a comment in Excel 2007 but not sure offhand how you would code this.

Your best option is to position your image on the sheet after inserting it I think.

Mary
Nov 9 '09 #4
Delerna
1,134 Expert 1GB
msquared is absolutely correct

The only thing the code I posted does is position the top left corner of the picture at the top left corner of the selected cell. It's not actually in the cell.
Nov 9 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: m1eyp | last post by:
I have a revision question bank on Excel. Two of these questions (160 & 161) have accompanying pictures, that I want to appear if either question is randomly selected. These images have filenames...
0
by: Mamatha | last post by:
Hi When i clicked a button, i want to insert data from listview in VB.NET to Excel sheet. If you know the solution either above or below is ok for me. I know how to insert from a textfile,but...
1
by: Esmail Bonakarian | last post by:
Greetings all, What is the best way to access specific records in an Excel file? I have an Excel file, I want to randomly and repeatedly (maybe around up to 50 times) draw some rows of data...
1
by: mgoold2002 | last post by:
I'm moving some code from Excel vbs into a .NET context and I'm very new to .NET. I'm trying to make this Excel vb code work in .NET. My questions are: how do I reference cells correctly using...
3
by: davnao | last post by:
I would like to open an existing workbook, select a work sheet and insert multiple rows at the top of the spreadsheet. Have the following code, but unsure of proper command & syntax for Insert row,...
2
by: Peter99 | last post by:
We are about to receive 500 excel spreadsheets from a client. The data has not been arranged in tabular form. Is it possible to import specific cells, say J10, M10, J15, M22 into an Access table...
1
by: accessvbanewbie | last post by:
I would like to export a recordset from access to excel but after each record is exported I want to insert a new row. The first recordset does this ok. However, the second recordset onwards does not...
3
by: JFKJr | last post by:
Hello everyone, I am trying to insert a picture in an excel spreadsheet cell using Access VBA. The following excel VBA code is working perfectly fine and I am able to insert picture in "A1" cell....
0
by: =?ISO-8859-1?Q?J=F6rg_Battermann?= | last post by:
Hello there, Is there any -reliable- way to extract certain, given ranges in excel files into either a picture (each) or into proper xhtml? I am asking because I am currently automating a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.