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: 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/



  #5   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



  #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: 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/



  #8   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

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 07:33 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"