Frown Face Question...

Any thoughts why this does not work?

-----

Sub Test()

Dim shp As Object, rng As Range
If Selection.Type = 7 Or Selection.Type = 8 Then
    If Selection.Type = 7 Then
        Set shp = Selection.InlineShapes(1)
        Set rng = shp.Range
    Else
        Set shp = Selection.ShapeRange(1)
        Set rng = shp.Anchor
    End If
    With ActiveDocument.Shapes.AddPicture(FileName:="C:\Documents and Settings\JOHN10\My Documents\My Pictures\Frown.bmp", LinkToFile:=msoFalse, SaveWithDocument:=msoTrue,(msoShapeSmileyFace, 475, 20, shp.Width / 13, shp.Height / 7, rng)
        .Line.ForeColor.RGB = RGB(186, 14, 29)
        .Line.Weight = 3#
        .Line.Visible = msoTrue
        .Fill.Transparency = 1#
        .Line.Visible = msoTrue
        .ScaleWidth 0.73, msoFalse, msoScaleFromTopLeft
        .ScaleHeight 0.54, msoFalse, msoScaleFromTopLeft
    End With
Else
    MsgBox "Please select a picture"
End If

End Sub
Craig JohnsonChief Technical Market StrategistAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

R_RajeshCommented:
You cant add them at the same time. Insert them one at a time...

With ActiveDocument.Shapes.AddShape(msoShapeSmileyFace, 475, 20, shp.Width / 13, shp.Height / 7, rng)
   
        .Line.ForeColor.RGB = RGB(186, 14, 29)
        .Line.Weight = 3#
        .Line.Visible = msoTrue
        .Fill.Transparency = 1#
        .Line.Visible = msoTrue
        .ScaleWidth 0.73, msoFalse, msoScaleFromTopLeft
        .ScaleHeight 0.54, msoFalse, msoScaleFromTopLeft
    End With
   
    With ActiveDocument.Shapes.AddPicture(FileName:="C:\Documents and Settings\JOHN10\My Documents\My Pictures\Frown.bmp", LinkToFile:=msoFalse, SaveWithDocument:=msoTrue)
        .Line.ForeColor.RGB = RGB(186, 14, 29)
        .Line.Weight = 3#
        .Line.Visible = msoTrue
        .Fill.Transparency = 1#
        .Line.Visible = msoTrue
        .ScaleWidth 0.73, msoFalse, msoScaleFromTopLeft
        .ScaleHeight 0.54, msoFalse, msoScaleFromTopLeft
    End With
0
R_RajeshCommented:
If you want to anchor it to the selected picture and adjust its dimension then use this modification.

With ActiveDocument.Shapes.AddPicture("C:\Documents and Settings\JOHN10\My Documents\My Pictures\Frown.bmp", 0, 1, 0, 0, shp.Width / 13, shp.Height / 7, rng)
0
Craig JohnsonChief Technical Market StrategistAuthor Commented:
Would like to place the frown face at the same location as the smiley face....thus I can choose.

ActiveDocument.Shapes.AddShape(msoShapeSmileyFace, 475, 20, shp.Width / 13, shp.Height / 7, rng)

I tried to put these settings.....475, 20 into the code you provided, but it did not work....ideas?

0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

R_RajeshCommented:
This should place both of them side by side...

Sub Test()
Dim shp As Object, rng As Range, shp1 As Object
If Selection.Type = 7 Or Selection.Type = 8 Then
    If Selection.Type = 7 Then
        Set shp = Selection.InlineShapes(1)
        Set rng = shp.Range
    Else
        Set shp = Selection.ShapeRange(1)
        Set rng = shp.Anchor
    End If
   Set shp1 = ActiveDocument.Shapes.AddPicture("C:\Documents and Settings\JOHN10\My Documents\My Pictures\Frown.bmp", 0, 1, 0, 0, shp.Width / 13, shp.Height / 7, rng)
   With shp1
        .Line.ForeColor.RGB = RGB(186, 14, 29)
        .Line.Weight = 3#
        .Line.Visible = msoTrue
        .Fill.Transparency = 1#
        .Line.Visible = msoTrue
        .ScaleWidth 0.73, msoFalse, msoScaleFromTopLeft
        .ScaleHeight 0.54, msoFalse, msoScaleFromTopLeft
    End With
    With ActiveDocument.Shapes.AddShape(msoShapeSmileyFace, shp1.Left + shp1.Width, 0, shp.Width / 13, shp.Height / 7, rng)
   
        .Line.ForeColor.RGB = RGB(186, 14, 29)
        .Line.Weight = 3#
        .Line.Visible = msoTrue
        .Fill.Transparency = 1#
        .Line.Visible = msoTrue
        .ScaleWidth 0.73, msoFalse, msoScaleFromTopLeft
        .ScaleHeight 0.54, msoFalse, msoScaleFromTopLeft
    End With

Else
    MsgBox "Please select a picture"
End If

End Sub
0
Craig JohnsonChief Technical Market StrategistAuthor Commented:
Here is my current code...

I would like the frown only on the upper righthand side of the screen....please

CWJ

----------------------------------
Sub Frown_Face()
'
' This creates a frown face

Dim shp As Object, rng As Range, shp1 As Object
If Selection.Type = 7 Or Selection.Type = 8 Then
    If Selection.Type = 7 Then
        Set shp = Selection.InlineShapes(1)
        Set rng = shp.Range
    Else
        Set shp = Selection.ShapeRange(1)
        Set rng = shp.Anchor
    End If
   Set shp1 = ActiveDocument.Shapes.AddPicture("C:\Documents and Settings\JOHNC04\My Documents\My Pictures\Frown.bmp", 0, 1, 0, 0, shp.Width / 13, shp.Height / 7, rng)
   With shp1
        .Line.ForeColor.RGB = RGB(186, 14, 29)
        .Line.Visible = msoFalse
        .Fill.Transparency = 1#
        .ScaleWidth 0.73, msoFalse, msoScaleFromTopright
        .ScaleHeight 0.54, msoFalse, msoScaleFromTopright
    End With

Else
    MsgBox "Please select a picture"
End If

End Sub
0
R_RajeshCommented:
use the pictures left and top property to position it

With shp1
        .Left = 450
        .Line.ForeColor.RGB = RGB(186, 14, 29)
0
R_RajeshCommented:
or you can use something like this

Set shp1 = ActiveDocument.Shapes.AddPicture("C:\Documents and Settings\JOHNC04\My Documents\My Pictures\Frown.bmp", 0, 1, 0, 0, shp.Width / 13, shp.Height / 7, rng)
With ActiveDocument.PageSetup
   shp1.Left = .PageWidth - .RightMargin - shp1.Width - .LeftMargin - .Gutter
   End With
   With shp1
        .Line.ForeColor.RGB = RGB(186, 14, 29)
        .Line.Visible = msoFalse
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.