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
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