Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default using VBA to insert a column of pictures

I have a column of file names and want to write a macro to insert th
pictures the files refer to in the cell to the right my code so far i

Filename = ActiveCell.Offset(0, -1)
ActiveSheet.Pictures.insert( _
"C:\Documents and Settings\12ahackett\Desktop\aspen smal
pics\re sized\(filename)"
).Select
the active cell being the insertion point, the variable "filename
being the Jpeg filename.
Any help on the correct syntax for the insert statement would b
appreciate

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default using VBA to insert a column of pictures

Dim Filename as String
Filename = ActiveCell.Offset(0, -1).Value
ActiveSheet.Pictures.insert _
"C:\Documents and Settings\12ahackett\Desktop" & _
"\aspen small pics\re sized\" & Filename & ".jpg"

if the cell includes the jpg extension, then you can delete that from the
string above.

--
Regards,
Tom Ogilvy


"andy hackett " wrote in
message ...
I have a column of file names and want to write a macro to insert the
pictures the files refer to in the cell to the right my code so far is

Filename = ActiveCell.Offset(0, -1)
ActiveSheet.Pictures.insert( _
"C:\Documents and Settings\12ahackett\Desktop\aspen small
pics\re sized\(filename)"
).Select
the active cell being the insertion point, the variable "filename"
being the Jpeg filename.
Any help on the correct syntax for the insert statement would be
appreciated


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default using VBA to insert a column of pictures

Andy,

Here is a code that you can work with. It's for a BMP. But it may giv
you some ideal.

Charles


Sub Get_picture()
Dim fname
fname = ActiveCell.Offset(0, -1)
ActiveSheet.Pictures.Insert ( _
"C:\Documents and Settings\Charles Harmon\My Documents\M
Pictures\") & fname<<fname wksh =101.bmp
End Su

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default using VBA to insert a column of pictures

Thanks Charles. That works great. Now I have to figure a way of workin
down the column. (as you will no doubt of guessed I'm new to VBA bu
enjoy learning !

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default using VBA to insert a column of pictures

As written, this would raise an error, even disregarding the wordwrap
problem.

--
Regards,
Tom Ogilvy

"Charles " wrote in message
...
Andy,

Here is a code that you can work with. It's for a BMP. But it may give
you some ideal.

Charles


Sub Get_picture()
Dim fname
fname = ActiveCell.Offset(0, -1)
ActiveSheet.Pictures.Insert ( _
"C:\Documents and Settings\Charles Harmon\My Documents\My
Pictures\") & fname<<fname wksh =101.bmp
End Sub


---
Message posted from http://www.ExcelForum.com/





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default using VBA to insert a column of pictures

andy,






This assumes all bmp is in column "A"Row 1 through ?? It loops throug
the colum for the bmp.


Sub Get_picture()
Dim fname
Dim rng As Range
Dim i As Integer
Set rng = Worksheets("sheet1").Cells(1, 1).CurrentRegion
For i = 1 To rng.Rows.Count
fname = rng(i, 1).Text
ActiveSheet.Pictures.Insert ( _
"C:\Documents and Settings\Charles Harmon\My Documents\M
Pictures\") & fname
Next
End Sub


Have fun.

Charle

--
Message posted from http://www.ExcelForum.com

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default using VBA to insert a column of pictures

Thanks again Charles,

Unfortunately I can't get this one to work. I have put all the fil
names in column A and changed the directory ref. to the correct one bu
the macro stops on one the activesheet.picture.insert lin

--
Message posted from http://www.ExcelForum.com

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default using VBA to insert a column of pictures

As written, this inserts all pictures in the activeCell, not next to the
cell with the name.

--
Regards,
Tom Ogilvy

"Charles " wrote in message
...
andy,






This assumes all bmp is in column "A"Row 1 through ?? It loops through
the colum for the bmp.


Sub Get_picture()
Dim fname
Dim rng As Range
Dim i As Integer
Set rng = Worksheets("sheet1").Cells(1, 1).CurrentRegion
For i = 1 To rng.Rows.Count
fname = rng(i, 1).Text
ActiveSheet.Pictures.Insert ( _
"C:\Documents and Settings\Charles Harmon\My Documents\My
Pictures\") & fname
Next
End Sub


Have fun.

Charles


---
Message posted from http://www.ExcelForum.com/



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default using VBA to insert a column of pictures

Andy,

Post your code and I'll look at it


Charle

--
Message posted from http://www.ExcelForum.com

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default using VBA to insert a column of pictures

It worked as written. It stacks all the pictures on the active cell.

--
Regards,
Tom Ogilv

--
Message posted from http://www.ExcelForum.com



  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default using VBA to insert a column of pictures

Tom,

Thanks for your help


Charle

--
Message posted from http://www.ExcelForum.com

  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default using VBA to insert a column of pictures

Charles wrote:
*Andy,

Post your code and I'll look at it


Charles *


Code copied in below.
I have all the picture ref files in column A and want the macro to ste
through the column and insert the picture in each adjacent cell

Sub Get_picture()
Dim fname
Dim rng As Range
Dim i As Integer
Set rng = Worksheets("sheet1").Cells(1, 1).CurrentRegion
For i = 1 To rng.Rows.Count
fname = rng(i, 1).Text
ActiveSheet.Pictures.insert ( _
"C:\Documents and Settings\12ahackett\Desktop\aspen small pics\r
sized\") & fname
Next
End Su

--
Message posted from http://www.ExcelForum.com

  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default using VBA to insert a column of pictures

I would assume he would the following addition:

Sub Get_picture()
Dim fname
Dim rng As Range
Dim i As Integer
Set rng = Worksheets("sheet1").Cells(1, 1).CurrentRegion
For i = 1 To rng.Rows.Count
fname = rng(i, 1).Text
rng(i,2).Select '<==
ActiveSheet.Pictures.Insert _
"C:\Documents and Settings\" _
& "Charles Harmon\My Documents\My Pictures\" _
& fname
Next
End Sub

But if he can't get past the Pictures.Insert line, it is unclear wha
his problem might be, especially if he was successful with the initia
suggestion for a single cell.

Just a note:
() are not required around the argument to Insert since it isn'
returning a value.

--
Regards,
Tom Ogilv

--
Message posted from http://www.ExcelForum.com

  #14   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default using VBA to insert a column of pictures

Check the path below to make sure it has spaces where they should be an
does not have spaces where they should not be.

Sub Get_picture()
Dim fname
Dim rng As Range
Dim i As Integer
Set rng = Worksheets("sheet1").Cells(1, 1).CurrentRegion
For i = 1 To rng.Rows.Count
fname = rng(i, 1).Text
rng(i,2).Select
ActiveSheet.Pictures.insert _
"C:\Documents and Settings\12ahackett\" & _
"Desktop\aspen small pics\re sized\" & fname
Next
End Sub

--
Regards,
Tom Ogilvy

andy hackett wrote:
*Code copied in below.
I have all the picture ref files in column A and want the macro t
step through the column and insert the picture in each adjacent cell

Sub Get_picture()
Dim fname
Dim rng As Range
Dim i As Integer
Set rng = Worksheets("sheet1").Cells(1, 1).CurrentRegion
For i = 1 To rng.Rows.Count
fname = rng(i, 1).Text
ActiveSheet.Pictures.insert ( _
"C:\Documents and Settings\12ahackett\Desktop\aspen small pics\r
sized\") & fname
Next
End Sub


--
Message posted from http://www.ExcelForum.com

  #15   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default using VBA to insert a column of pictures

Charles, Tom,
Thank you very much for your help and the time you have put in.
The fault was mine in that I had column headers which meant the firs
cell was not a picture filename.
As a "newbie" I'm now working through your code to figure out how i
works!
It's great to have peole like yourselves who are prepared to take th
time to help others out

Thanks,

And

--
Message posted from http://www.ExcelForum.com

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
Can't insert pictures laurie New Users to Excel 2 April 5th 23 01:21 PM
Insert pictures AZU Excel Discussion (Misc queries) 5 March 6th 09 05:28 PM
Need Help with auto insert of pictures Bradley Wolosz New Users to Excel 3 August 25th 08 12:28 PM
can't insert, delete or move pictures parker Excel Discussion (Misc queries) 1 February 18th 05 01:03 AM
Activesheet.Pictures.Insert dchow Excel Programming 2 September 24th 03 07:22 PM


All times are GMT +1. The time now is 01:19 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"