Imar,
So i can loop through the document, and find the _merge_ fields, not just
the regular fields. because all the fields in the document arent really
fields that the user fills out. they are mail merge fields that are
automatically filled out.
ill give it a shot. and see what i can come up with.
thanks for the help!!
Daniel
-----Original Message-----
From: Imar Spaanjaars [mailto:e_mar@y...]
Sent: Thursday, March 15, 2001 10:24 AM
To: professional vb
Subject: [pro_vb] Re: Last Ditch Effort
Hi Daniel,
I think that can be done, more or less, with the code
I supplied.
I cut the code from a word template that has a couple
of form fields in it.
Once you create a new document based on this template,
a dialog pops up, asking you for a couple values.
These values are saved to disk for re-use, and are
also inserted in the formfields that are present (The
dialog is built dynamically, based on the presence of
the formfields. That is one of the reasons these
fields need a bookmark attached to it).
Anyway, I think you can do something like this as
well. Word is a bit tricky to understand and control,
but once you get into it, things get better and seem
to make more sense.
So what I think you should do is loop through your
document and search for the field that has the
doctor's name (it IS still in a field, right?).
Once you have a reference to the field, you can
replace it with a picture, or simply add the picture
afterwards.
If you still can't get it to work, A) look in the
MSDN, near the link I sent you. A lot of info about
programming Word is supplied there. B) Send me a copy
of the Word document (Imar@S...) and I might
be able to take a look at it.
Imar
--- Daniel O'Dorisio <dodorisio@h...> wrote:
> ok, so what if i put the merge data in one of the
> form fields?? im not sure
> if that can be done. but i am willing to do
> anything, im kinda at the end of
> my rope.
>
> what i meant, was somthing like
>
> (asp page with ado)
> set objRs = Server.CreateObject("ADODB.Recordset")
> ->objRs("fieldName")
>
> is there some wat to access the data in the mail
> merge field? like
> objMerge("fieldname") i know this probally is clear
> as mud. but that is
> kinda what i want to do. (i think)
>
> our requirements are:
> there is a pre programmed word macro thinggy, that
> grabs paitent data (based
> on a popup window that the paitent id is inputted
> into) and then the popup
> window saves all the paitent data to a txt file.
> the macro sets up the correct document(which is also
> selected in a popup
> window, with the merge data (drawn from the txt
> file)
> what i need to do, is in each document, write a
> little code that will insert
> a image of the doctors signature, based on the
> doctor name that is grabbed
> (there is only 4 doctors, so i was thinking about
> select case.
>
> if you can understand this (im not really good at
> explaining stuff, unless i
> can use my hands:-), and know how i can accomplish
> this. it would be
> GREAT!!!!! give me your bank account number :-)
> hehe.
>
> THANKS!!
> Daniel
>
>
> -----Original Message-----
> From: Imar Spaanjaars [mailto:e_mar@y...]
> Sent: Thursday, March 15, 2001 8:16 AM
> To: professional vb
> Subject: [pro_vb] Re: Last Ditch Effort
>
>
> Aha, It thought you had already figured that out.
>
> Here is something that might help:
> This code loops through all the fields in a
> document.
> If the field is a custom input field, we change its
> value if it has a bookmark attached to it. (In our
> application, one of the requirements was that a
> custom
> field needed to have a bookmark to have its value
> changed. Of course this is something you can easily
> change.)
>
> I am not sure whether you can reference merge fields
> the same as the FormFields, but this might at least
> give you a clue where to look.
> Not sure what you mean by ADO and ASP in this
> contect,
> though
>
>
> Imar
>
>
>
> ' loop through FormFields collection
> For Each objField In ActiveDocument.FormFields
> ' If it is a custom input field
> If objField.Type = wdFieldFormTextInput Then
> If objField.Range.Bookmarks.Count > 0 Then
> ' Field has a bookmark
> so set its value
> sValue = "A Demo text"
> objField.Result = sValue
> End If
> End If
> Next
>
>
>
> --- Daniel O'Dorisio <dodorisio@h...> wrote:
> > what about accessing the value in the merge
> field??
> >
> > is it similar to ado in asp??
> >
> > Daniel
> >
> > -----Original Message-----
> > From: Imar Spaanjaars [mailto:e_mar@y...]
> > Sent: Thursday, March 15, 2001 3:07 AM
> > To: professional vb
> > Subject: [pro_vb] Re: Last Ditch Effort
> >
> >
> > Hi Daniel,
> >
> > The following code loads a picture at the current
> > position.
> > You'll have to move the current position yourself
> > first with a Range or a Selection (I think) to the
> > position where you want to insert the image. Then
> > use
> > this code:
> >
> > Selection.InlineShapes.AddPicture FileName:= _
> > "D:ImagesMyImage.gif", LinkToFile:= _
> > False, SaveWithDocument:=True
> >
> > This is a very trivial example: take a look at the
> > MSDN for more info on AddPicture
> >
>
http://msdn.microsoft.com/library/officedev/office97/output/F1/D4/S5A8A3.HTM
> >
> > Hope this helps,
> >
> > Imar
>
>