Combo Box in a Userform for Images (Macro Help)

  • Thread starter Thread starter jlawson
  • Start date Start date
J

jlawson

Does anyone know of a macro that will list the names of any images in
a folder (using a combo box or list box), the user selects the image's
name, clicks "OK" on the userform and the image is inserted into the
document? These are .jpg images.
 
JL:

Sorry, that wasn't very helpful. I didn't read both your subject line and
message and think it through.

I hope someone has a macro already built that they'll post for you.
Otherwise, you're going to have to figure out how to get the user to specify
the folder, read the JPG extension files in that folder into an array, fill a
combo or list box with the array, and react to the user selecting a file.

Bear
 
Does anyone know of a macro that will list the names of any images in
a folder (using a combo box or list box), the user selects the image's
name, clicks "OK" on the userform and the image is inserted into the
document? These are .jpg images.

You can just invoke the built-in Insert Picture dialog from the macro.

Dialogs(wdDialogInsertPicture).Show

More help and examples are at
http://www.word.mvps.org/FAQs/MacrosVBA/WordDlgHelp.htm.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
JL:

Sorry, that wasn't very helpful. I didn't read both your subject line and
message and think it through.

I hope someone has a macro already built that they'll post for you.
Otherwise, you're going to have to figure out how to get the user to specify
the folder, read the JPG extension files in that folder into an array, fill a
combo or list box with the array, and react to the user selecting a file.

Bear

You're on the right track, though. You can just invoke the built-in
Insert Picture dialog from the macro.

Dialogs(wdDialogInsertPicture).Show

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
The idea is the user opens the template, a GUI form will open on a
Doc_New command, the user will fill in the patient information (I'm
going to build in required fields) and add the physician's name and
signature. The Physician's signature is going to reside locally on
the PC and be tightly controlled by Medical Records. I would need the
dialog box to point to a certain folder that would just contain the
signatures. I was playing around with the "With
Dialogs(wdDialogInsertPicture)" property. The signature would have to
be inserted at a certain bookmark. The Clinical Staff are not to savy
with computers so I was trying to make it as easy as possible for
them.

The Staff can then print out the order form for the patient and send
it to the hospital or (in another version) print directly to the pre-
admissions department. Everything can be prepared for the patient
before they even arrive. Our hospital is non-profit and we wouldn't
make any money from this. The biggest benefit would be to the
patient.

Thank you for all your help so far!

-Josh
 
JL:

Why don't you maintain a Word table (could be right in the template itself)
that links the doctors' names (column 1) with the full path to the JPG
images (column 2). Then your code just shows a list of the doctor's names for
the user to pick. Having picked a name, your code now knows exactly where to
go to get the JPG (i.e. knows the correct pathname for the image to insert).

Bear
 
The only problem with that is this template will go to multiply
offices that would have four or five different physicians in them.
Medical Records doesn't want one office to have the other offices'
signatures. I could build a path like that and have a "IF Then" error
handler built it. The clinical staff could put in their doc's
initials and have it pop up, if not then a msgbox will tell them it's
not there. The other problem with that is everytime there is a new
physician I'l have to update the template and repost it on the
intranet. The only digital Signature in the hospital for code signing
is on my PC (lucky me).
 
JL:

All you or the user has to do is update the table with the doctor's name and
the path to the image. Didn't you say the user had to specify the doctor? How
does the user do that if you're not storing a list somewhere? Is it all based
on the filename of the JPG of their signatures?

Bear
 
Not sure if this is what you meant but I've created a txt file in a
folder on the C drive that has all the physician names in it for that
office. The combo box in the userform goes out and looks for that txt
file and lists the content as its dropdown. The user select the name
they want and when they click the Cmd button, to add the information
to the form, a marco matches the name in the combox with a .jpg image
and inserts it as a inline shape.

My next problem is inserting a .jpg behind text insead of inline with
it. I guess I should create another thread because it will be a
different problem.

Thank you for your help!
 
JLawson:

That's close to what I meant. "Exactly" what I meant was a two-column table
in Word that you or the local site admin could maintain. The first column
would be the doc's name as used in the combo. The second column would be the
filename of the signature file, maybe including path information, maybe not.

The only advantage this approach has is to give you more freedom about how
the signature file names are built and where they are stored. May not be
needed.

But it sounds like you're well under way again. So on to the next problem...

Bear
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top