image from database field

K

Keith G Hicks

I've got a bunch of word vba code (in Access) that's being used to insert
signatures into documents. The current code puts the initials of the person
into the document and then I'm running some autotext code after that line to
replace the initials with the signature that's stored in the template. Most
of the time that works just fine but on some machines we occasionally get
some odd errors that just don't seem to be predictable. I'd like to change
this code so that it is no longer using teh signatures stored in the dot
file but instead gets them from the signatures we hvae stored in the
database. I already do this for some Access reports but want to do the same
for the word docs. But I'm not sure how to do this.

Here's what I'm doing right now:

Dim rsLettersAttySigs As Recordset
Set rsLettersAttySigs = CurrentDb().OpenRecordset("SELECT
strAttorneyName, objSignature FROM tblAttorneys WHERE OrderInSignatures IS
NOT NULL ORDER BY OrderInSignatures", dbOpenSnapshot)

rsLettersAttySigs.MoveLast
If rsLettersAttySigs.RecordCount > 0 Then

rsLettersAttySigs.MoveFirst

'Find the bookmark in the table
docWord.Bookmarks("AttySigTableStart").Select

iNumSigs = rsLettersAttySigs.RecordCount
iNumRowSigs = Int(iNumSigs / 3) + Sgn((iNumSigs / 3 - Int(iNumSigs /
3))) '3 columns of signatures, each with 2 rows (first row is signature,
second row is printed name)

For iRowCount = 1 To iNumRowSigs
'Put the signature rows in
For iColCount = 1 To 3

If Not rsLettersAttySigs.EOF Then 'this is because of the
"for iColCount = 1 to 3"

With objWord

.Selection.InsertAfter rsLettersAttySigs!strAttorney
.Selection.Range.UnderLine = wdUnderlineSingle
.Selection.Range.Font.Size = 10
.Selection.Range.Font.Bold = False
.Selection.Cells.VerticalAlignment =
wdCellAlignVerticalBottom

'**************************
' >>>>>>> I had code here to do teh autotext
replacement for the initials but this is what I want to change so that
instead of teh above it puts the objSignature in right away (stored as an
OLE Object in the database)
'**************************

End With
On Error GoTo Err_subGetAttySigsForLetters
rsLettersAttySigs.MoveNext

End If

objWord.Selection.MoveRight Unit:=wdCell

Next iColCount

End If
 
D

Doug Robbins - Word MVP

I would use an IncludePicture field inside of which is nested a DocVariable
field and then use code to set the value of the document variable to the
path and filename of the appropriate signature file and then update the
field so that it displays the required signature.

--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.
 
K

Keith G Hicks

I was trying to get the signature images from a database field, not from
files on disc.

Anyway, I decided to bail on getting the signatures out of the database. I
opted to store the signatures on disc and get them from there. Using
Selection.Range.InlineShapes.AddPicture and it works just fine.
 

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

Top