Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: Thu, 5 Jun 2008 11:25:01 -0700,    group: microsoft.public.word.vba.beginners        back       


Inserting footnote into automated word document from Access   
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.

**
I am having little luck in solving this issue, so another thing that may 
help is, what is the best way to insert a footnote or endnote into word 
document when you have a certain field selected(highlighted).
date: Thu, 5 Jun 2008 11:25:01 -0700   author:   Aaron

Re: Inserting footnote into automated word document from Access   
Is your code releasing the variables - that is setting the WordApp2 and 
Docs2 to nothing at the end of it?

-- 
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Aaron"  wrote in message 
news:58F61835-0FDA-4D08-B594-02C68E1F501E@microsoft.com...
> 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.
>
> **
> I am having little luck in solving this issue, so another thing that may
> help is, what is the best way to insert a footnote or endnote into word
> document when you have a certain field selected(highlighted).
date: Fri, 6 Jun 2008 06:14:08 +1000   author:   Doug Robbins - Word MVP

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us