• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 324
  • Last Modified:

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
0
Craig_W_Johnson
Asked:
Craig_W_Johnson
  • 5
  • 2
1 Solution
 
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_W_JohnsonAuthor 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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_W_JohnsonAuthor 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

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now