PDA

View Full Version : INsert Image From Userform



TazzBullet
10-17-2012, 01:19 AM
Hello Forum

I am fairly new to Word VBA and have spent a couple of days searching and reading up on developing a userform which on completion builds a set of detailed instructions. I have figured out the text based sections and the combo box additions but there is one element I am stuck on.
I have a check box page on my userform which when checked I need it to place (on unload) text at a bookmark (in a table) then allows a selection to be made from a drop down list on the userform which will place a specific image in to the "cell" above the text cell.
This document builder on completion will be for use on a number of PC's but I can't get my head around that if I insert a path to the image (which is held in a folder) it will be of use only on my PC.

Am I missing something? :dunno
Any advice would be appreciated.

Thanks in advance.

TazzBullet

gmaxey
10-17-2012, 04:37 AM
Obviously in order to work, everyone (or every PC in use) is going to have to have access to the folder containing the images. Is that folder going to be a network shared folder, or is everyone supposed to have their own folder on thier own PC?

TazzBullet
10-17-2012, 04:47 AM
Obviously in order to work, everyone (or every PC in use) is going to have to have access to the folder containing the images. Is that folder going to be a network shared folder, or is everyone supposed to have their own folder on thier own PC?

Hello gmaxey;
Yes they would have the folder on their own PC, It is as I expected.

The main item I am struggling with is the placing an image selected from a combobox in to a bookmark. All of the images are sized correctly for direct insertion with no formatting required.

gmaxey
10-17-2012, 05:02 AM
Well if everyone has the same folder in the same path (e.g., C:\DocBuilder\Images), if it works for you then it should work for them. Otherwise, you would have to provide some means for the user to identify the image folder and then store that path that they identified for future reference. Very crude, but hopefully you will get the idea:

Sub ScratchMacro()
'A quick macro scratch pad created by Greg Maxey
SaveSetting "Your App Name", "Settings", "ImagePath", InputBox("Where are your images?", "Image Path", "C:\DocBuilder\Images\")
'Other code
'Insert the image
ActiveDocument.InlineShapes.AddPicture GetSetting("Your App Name", "Settings", "ImagePath") & "ImageName.jpg", False, True, Selection.Range
End Sub


In practice, you would replace the input box, with a folder picker dialog. Note: SaveSetting and GetSetting are describe in Help and store the values in the users registry.