MS Word

ssingh75

Well-known Member
Joined
Jan 5, 2012
Messages
518
Hi All,

Can anyone guide me that how can i add macro to shape in word document. I've below code but want to activate when someone will click on the shape to add image.

Code:
Private Sub CommandButton1_Click()

    With Application.FileDialog(msoFileDialogFilePicker)
        .AllowMultiSelect = False
        .ButtonName = "Submit"
        .Title = "Select an image file"
        .Filters.Add "Image", "*.gif; *.jpg; *.jpeg", 1
        If .Show = -1 Then
            ' file has been selected

            ' e.g. show path in textbox
            Me.TextBox1.Text = .SelectedItems(1)

            ' e.g. display preview image in an image control
            Me.Image1.PictureSizeMode = fmPictureSizeModeZoom
            Me.Image1.Picture = LoadPicture(.SelectedItems(1))
        Else
            ' user aborted the dialog

        End If
    End With

End Sub


---Thanks in advance
 
Last edited by a moderator:

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Your code seems designed for use with a userform or ActiveX control. Why not use a picture content control instead? No code required.

PS: When posting code, please use the code tags, indicated by the # button on the posting menu instead of posting everything as HTML. Without the code tags, your code loses much of whatever structure it had.
 
Last edited:
Upvote 0
Your code seems designed for use with a userform or ActiveX control. Why not use a picture content control instead? No code required.

PS: When posting code, please use the code tags, indicated by the # button on the posting menu instead of posting everything as HTML. Without the code tags, your code loses much of whatever structure it had.


I'm not sure how to use the picture content control in MS word...Could you help me with some intial code.....thanks in advance.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,169
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top