Issue with adding a footnote into automated document from Access

A

Aaron

Hello, I am fairly new to Access databases and programming with VBA. However,
my problem is this:

I have a database in which I write information to a word document table
using fields. The table size is variable so I have code which copies and
pastes the rows of the table and updates the fields as required. In the
bottom row of the table, using VBA code in Access I select the single cell I
would like to add a footnote too. The code I have for that is this;

where cellcounter indicates the particular I am selecting. When the word
document
opens the correct cell and field text is selected.

'This is how I create my word document
Dim wordApp2 As New Word.Application
Dim docs2 As Word.Documents
Dim doc2 As Word.Document

Set docs = wordApp.Documents
'Telling to write the records to the Report in the templates folder
Set doc = docs.ADD(strTemplateDir & "rpt_Select" & "8" & ".dot")
Dim props As Object

Set props = doc.CustomDocumentProperties
Set wordAppForQuit = wordApp

'This is the code that is supposed to insert the footnote every time
With wordApp
.Selection.Fields.Update
.Selection.Tables(1).Cell(cellcounter, 1).Select

.Visible = True
ActiveDocument.Footnotes.ADD Range:=Selection.Range, _
text:="refers to total number of recognized labs"

End With

My issue is this, when I open up the Access application to generate the
report with
the footnote, the first time I generate the Word report the footnote is
successfully placed. However, once I close the word report without closing
the Access application and try to generate the report again, the report
prints fine but returns an error when inserting the footnote. The footnote is
not inserted. When I close the entire Access database and reopen it, it
successfully inserts the footnote the first time around but returns an error
and does not insert the footnote in the word document any time after the
first time until I close and reopen Access again.

I am using MS Office 2003 and do not really know where to start to solve
this issue, any suggestions or recommendations would be highly appreciated
and helpful.
 
P

patito

hola grupo dejeme contarles que no hablo ingles por eso no les puedo
entender nada será mucha molestia que me pudieran escribir en español por
favor si gracias
 
L

Larry Daugherty

The error number and description of the error may be a clue. If you
have your options set to break on Unhandled errors or break on All
errors, you should be invited to debug it. When you elect to do so,
the debugger should be halted with the line of code causing the error
highlighted..

It would be a good idea to set a breakpoint somewhere in that code so
that your code will halt and allow you to inspect the values of
variables even when there is no error.

Good luck.

HTH
 

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