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

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
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,213,494
Messages
6,113,972
Members
448,537
Latest member
Et_Cetera

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