PDA

View Full Version : Automatically select and Insert Picture/Clipart



coliervile
07-26-2007, 06:36 AM
I have the following code (thanks to VBA Express) that allows a user to select a picture/clipart and insert it in a dodument. I use it to resemble a watermark eveb though it's not a true watermark. What I would like the coding to do is follow the File Path, C:\Documents and Settings\Charlie Llamas\My Documents\My Pictures\Microsoft Clip Organizer - CG145 (Clipart Image), and select and insert the clipart image when I run the macro. I would also like to find a coding when the macro is run that removes the clipart image, similar to the RemoveWaterMark macro I have in my Word doc that removes the wordart. Please take a look and I would greatly appreciate your ideas and suggestion.

Best regards,

Charlie

lucas
07-28-2007, 10:22 AM
Hi coliervile,
I got your email and I apolgize for not being around lately. I have been really busy(and no end in sight) so I hope you have gotten some help from others here at the forum. When I get caught up I will revisit this. As it is I barely have a minute to check in here once in a while.

coliervile
07-28-2007, 04:57 PM
Thanks lucas for your reply. I haven't had much help thus far with ideas. I understand about being busy and I really appreciatre all of the assistance I've received from VBAX. Look forward to hear from you.

Best regards,

Charlie

geekgirlau
07-30-2007, 12:05 AM
Hi Charlie,

There's no code in the attachment - are you wanting the macro to allow the user to browse to any image and then insert it in the document, or just insert a specific image in the current document? The part of the macro that inserts an image can be easily recorded with the macro recorder: something like


Selection.InlineShapes.AddPicture FileName:= _
"C:\Documents and Settings\My Documents\MyPic.jpg", _
LinkToFile:=False, SaveWithDocument:=True

coliervile
07-30-2007, 08:12 AM
Thanks for your reply "geekgirlau". I'm wanting the macro to insert a specific clipart/picture. I also need a marco that removes the same Clipart/picture. The macro would be run from the tool/marocs tool bar.

Best regards,

Charlie

fumei
07-30-2007, 12:13 PM
Taking it out is a little more tricky than putting it in. If you are going to be doing this oftn enough, bookmark them when you insert. Deleting a bookmark is easy. Identifying a Shape (so you can delete it) can get ugly. Certainly not impossible, but bookmarking it would make it much easier.

coliervile
07-31-2007, 06:48 AM
Here's the coding that I have to insert a clpiart image from Microsoft Clipart Organizer (a file in My Pictures). I the macro when run goes to My Pictures file and opens it. I want the macro to go a bit further and go into the Microsoft Clipart file and insert CG145,the image I want inserted into the word document.

' \\ This sub inserts a Shape (Flowting) Picture to the selection
Sub InsertFlowtingPictureDialog()
Dim oDialog As Word.Dialog
' \\ Get a handle to the Insert picture dialog
Set oDialog = Dialogs(wdDialogInsertPicture)

' \\ Work with dialog
With oDialog
' \\ Display the dialog
.Display

' \\Insert (file://\\Insert) Shape Picture if the Name property (Filepath) <> ""
' \\ Set Left, Top, Width and Height properties to position the shape
If .Name <> "" Then
ActiveDocument.Shapes.AddPicture FileName:=.Name, _
LinkToFile:=False, _
SaveWithDocument:=True, _
Left:=274, _
Top:=355, _
Width:=105, _
Height:=115, _
Anchor:=Selection.Range
End If
End With

' \\ Clean up
Set oDialog = Nothing
End Sub

Any ideas would be appreciated. I will look at you idea Gerry about the bookmark.

Best regards,

Charlie

fumei
08-01-2007, 12:28 PM
Please use the VBA code tags. Thanks.

coliervile
08-01-2007, 01:25 PM
Sorry about that. Here's the coding that I have to insert a clipart image from Microsoft Clipart Organizer (a file in My Pictures). I the macro when run goes to My Pictures file and opens it. I want the macro to go a bit further and go into the Microsoft Clipart file and insert CG145,the image I want inserted into the word document.


' \\ This sub inserts a Shape (Flowting) Picture to the selection
Sub InsertFlowtingPictureDialog()
Dim oDialog As Word.Dialog
' \\ Get a handle to the Insert picture dialog
Set oDialog = Dialogs(wdDialogInsertPicture)

' \\ Work with dialog
With oDialog
' \\ Display the dialog
.Display

' \\Insert (file://insert/) Shape Picture if the Name property (Filepath) <> ""
' \\ Set Left, Top, Width and Height properties to position the shape
If .Name <> "" Then
ActiveDocument.Shapes.AddPicture FileName:=.Name, _
LinkToFile:=False, _
SaveWithDocument:=True, _
Left:=274, _
Top:=355, _
Width:=105, _
Height:=115, _
Anchor:=Selection.Range
End If
End With

' \\ Clean up
Set oDialog = Nothing
End Sub

Any ideas would be appreciated. I will look at you idea Gerry about the bookmark.

Best regards,

Charlie