473,511 Members | 15,126 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Insert a picture in specific cells in Excel

1 New Member
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 21256
Dököll
2,364 Recognized Expert Top Contributor
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 Recognized Expert Top Contributor
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 Recognized Expert Moderator MVP
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 Recognized Expert Top Contributor
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
3979
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
10401
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
4609
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
9754
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
15814
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
4091
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
3043
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
20723
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
1603
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
7137
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7349
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
7417
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
7506
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
5659
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5063
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...
0
3219
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
445
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.