Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Can't insert pictures | New Users to Excel | |||
Insert pictures | Excel Discussion (Misc queries) | |||
Need Help with auto insert of pictures | New Users to Excel | |||
can't insert, delete or move pictures | Excel Discussion (Misc queries) | |||
Activesheet.Pictures.Insert | Excel Programming |