Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default can pictures be inserted into comments


Can anyone tell me if it is possible to insert a number of pictures (one
for each cell in a column) automatically. I can do this manually but
would like to automate the process for say 100 rows. I have the picture
jpeg number in an adjacent cell in the same row.

Thanks in advance


--
tryer
------------------------------------------------------------------------
tryer's Profile: http://www.excelforum.com/member.php...o&userid=16546
View this thread: http://www.excelforum.com/showthread...hreadid=466666

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default can pictures be inserted into comments

One way...

Option Explicit
Sub testme()
Dim myCell As Range
Dim myRng As Range
Dim testStr As String
Dim PictFileName As String

Set myRng = Selection
For Each myCell In myRng.Cells

PictFileName = myCell.Offset(0, -1).Value

testStr = ""
On Error Resume Next
testStr = Dir(PictFileName)
On Error GoTo 0

If testStr = "" Then
'do nothing, picture not found
Else
If myCell.Comment Is Nothing Then
myCell.AddComment Text:="new comment here!" 'or ""
End If
myCell.Comment.Shape.Fill.UserPicture PictFileName
End If

Next myCell

End Sub

This assumes that the full filename of the picture that should be used is to the
left of the cell.

Select your range that should get the comments and try it out.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

tryer wrote:

Can anyone tell me if it is possible to insert a number of pictures (one
for each cell in a column) automatically. I can do this manually but
would like to automate the process for say 100 rows. I have the picture
jpeg number in an adjacent cell in the same row.

Thanks in advance

--
tryer
------------------------------------------------------------------------
tryer's Profile: http://www.excelforum.com/member.php...o&userid=16546
View this thread: http://www.excelforum.com/showthread...hreadid=466666


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default can pictures be inserted into comments

Sub AddPictures()
Dim shp As Picture
For Each cell In Range("B3:B30")
cell.Select
Set shp = ActiveSheet.Pictures.Insert( _
"C:\images" & cell.Value & ".jpg")
Next
End Sub

might be a start.

--
Regards,
Tom Ogilvy

"tryer" wrote in
message ...

Can anyone tell me if it is possible to insert a number of pictures (one
for each cell in a column) automatically. I can do this manually but
would like to automate the process for say 100 rows. I have the picture
jpeg number in an adjacent cell in the same row.

Thanks in advance


--
tryer
------------------------------------------------------------------------
tryer's Profile:

http://www.excelforum.com/member.php...o&userid=16546
View this thread: http://www.excelforum.com/showthread...hreadid=466666



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default can pictures be inserted into comments

Darn subject line questions <vbg!

Tom Ogilvy wrote:

Sub AddPictures()
Dim shp As Picture
For Each cell In Range("B3:B30")
cell.Select
Set shp = ActiveSheet.Pictures.Insert( _
"C:\images" & cell.Value & ".jpg")
Next
End Sub

might be a start.

--
Regards,
Tom Ogilvy

"tryer" wrote in
message ...

Can anyone tell me if it is possible to insert a number of pictures (one
for each cell in a column) automatically. I can do this manually but
would like to automate the process for say 100 rows. I have the picture
jpeg number in an adjacent cell in the same row.

Thanks in advance


--
tryer
------------------------------------------------------------------------
tryer's Profile:

http://www.excelforum.com/member.php...o&userid=16546
View this thread: http://www.excelforum.com/showthread...hreadid=466666


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default can pictures be inserted into comments


Dave,

Thank you for that advice. I have edited the filenames and paths an
got it working OK. Now I am trying to resize the inserted picture. Th
code I have added is:-
myCell.Comment.ShapeRange.LockAspectRatio = msoTrue
myCell.Comment.ShapeRange.Height = 143.25
myCell.Comment.ShapeRange.Width = 248.25

Unfortunately this does not work. Any suggestions

--
trye
-----------------------------------------------------------------------
tryer's Profile: http://www.excelforum.com/member.php...fo&userid=1654
View this thread: http://www.excelforum.com/showthread.php?threadid=46666



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default can pictures be inserted into comments

I would think that if you lock the aspect ratio, then you only have to change
the width or the height--not both.

I just added a couple of more lines to the existing routine...

Else
If myCell.Comment Is Nothing Then
myCell.AddComment Text:="new comment here!" 'or ""
End If
myCell.Comment.Shape.Fill.UserPicture PictFileName
myCell.Comment.Shape.LockAspectRatio = msoTrue
myCell.Comment.Shape.Height = 143.25
End If



tryer wrote:

Dave,

Thank you for that advice. I have edited the filenames and paths and
got it working OK. Now I am trying to resize the inserted picture. The
code I have added is:-
myCell.Comment.ShapeRange.LockAspectRatio = msoTrue
myCell.Comment.ShapeRange.Height = 143.25
myCell.Comment.ShapeRange.Width = 248.25

Unfortunately this does not work. Any suggestions?

--
tryer
------------------------------------------------------------------------
tryer's Profile: http://www.excelforum.com/member.php...o&userid=16546
View this thread: http://www.excelforum.com/showthread...hreadid=466666


--

Dave Peterson
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
Inserted Pictures are very Large Janet Excel Discussion (Misc queries) 0 February 28th 08 08:22 AM
my inserted pictures are always aligned to a cell Duangruthai Excel Discussion (Misc queries) 2 April 20th 06 02:57 PM
Pictures inserted into a message disappear Anomalia Excel Discussion (Misc queries) 1 December 24th 05 02:51 PM
Inserted Pictures Do Appear jyoon Excel Discussion (Misc queries) 0 June 9th 05 04:44 PM
Resize and resample pictures inserted Bert[_3_] Excel Programming 0 November 7th 04 07:37 PM


All times are GMT +1. The time now is 03:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"