DougDR
Board Regular
- Joined
- Jun 6, 2011
- Messages
- 121
I have a sheet that is a stock system I use for an Ecommerce business. What I wanted was to be able to automatically have a picture of the product placed into the comment of the description cell.
For this I gave the following info : “I have a stock number in ColumnE ... a description in ColumnK and a picture name (name.jpg) in ColumnBH and in cell CD11 a formular “=CD10&"\"&E11&"\"&BH11” which gives me a value of “E:\My Documents\Bid or Buy\New SearchDesign Stock\SD-CC-0001\SD151e.jpg” The SD-**-#### is the folder where the picture lies.
Thanks to SuperFerret who gave me the following code the placement of the pictures work great
The only problem was, a small one but important, the size of the comments. She suggested that I record a macro resizing a comment to see the code, this I did.
The problem now is where in her code does the resizing code go??????
The first code places the picture the second is the recorded macro.
Secound
For this I gave the following info : “I have a stock number in ColumnE ... a description in ColumnK and a picture name (name.jpg) in ColumnBH and in cell CD11 a formular “=CD10&"\"&E11&"\"&BH11” which gives me a value of “E:\My Documents\Bid or Buy\New SearchDesign Stock\SD-CC-0001\SD151e.jpg” The SD-**-#### is the folder where the picture lies.
Thanks to SuperFerret who gave me the following code the placement of the pictures work great
The only problem was, a small one but important, the size of the comments. She suggested that I record a macro resizing a comment to see the code, this I did.
The problem now is where in her code does the resizing code go??????
The first code places the picture the second is the recorded macro.
Code:
Option Explicit
Sub Add_Comments()
Dim myPict As Object
Dim curWks As Worksheet
Dim myRng As Range
Dim myCell As Range
Set curWks = Sheets(" ListingControl") ' Change to suit
With curWks
Set myRng = .Range("CD11", .Cells(.Rows.Count, "CD").End(xlUp))
End With
curWks.Columns(" K").ClearComments
For Each myCell In myRng.Cells
If Trim(myCell.Value) = "" Then
'do nothing
ElseIf Dir(CStr(myCell.Value)) = "" Then
'picture not there!
MsgBox myCell.Value & " Doesn't exist!"
Else
With myCell.Offset(0, -71) '71 columns to the left of BH (K)
.AddComment("").Shape.Fill.UserPicture (myCell.Value)
End With
End If
Next myCell
End Sub
Secound
Code:
Sub Macro4() ' ' Macro4 Macro ' Macro recorded 2011/06/15 by DOUG DAVEY ' ' Range("F10").AddComment Range("F10").Comment.Visible = False Range("F10").Comment.Text Text:="" With Selection.Font .Name = "Tahoma" .FontStyle = "Bold" .Size = 8 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = xlAutomatic End With Selection.ShapeRange.Fill.Transparency = 0# Selection.ShapeRange.Line.Weight = 0.75 Selection.ShapeRange.Line.DashStyle = msoLineSolid Selection.ShapeRange.Line.Style = msoLineSingle Selection.ShapeRange.Line.Transparency = 0# Selection.ShapeRange.Line.Visible = msoTrue Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 0, 0) Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255) Selection.ShapeRange.Fill.Visible = msoTrue Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 255, 255) Selection.ShapeRange.Fill.BackColor.SchemeColor = 80 Selection.ShapeRange.Fill.UserPicture "E:\My Documents\My Pictures\Globe.jpg" Selection.ShapeRange.LockAspectRatio = msoTrue Selection.ShapeRange.Height = 141.75 Selection.ShapeRange.Width = 141.75 Selection.ShapeRange.ScaleHeight 1.39, msoFalse, msoScaleFromTopLeft Selection.ShapeRange.ScaleHeight 1.11, msoFalse, msoScaleFromTopLeft End Sub
Last edited: