Replace Text in Footnote in Ms WORD or Endnote

Dear EE Experts,

I am trying to replace some text from my access db into a footnote or end not my sample code is below.

it say cannot find defined data type footnote

any help would be helpful

Dim rng As Range
Dim FTNT As Footnote
 
i = 0
c = 0
r = 0
 
For Each FTNT In ActiveDocument.Footnotes
 
    Set rng = FTNT.Range
   
    i = i + 1
   
    With rng.Find
        .Text = "<clientname>"
        .MatchWildcards = False
        .Replacement.Text = cmb_organizationName
        .Execute Replace:=wdReplaceAll
    End With
 
Next
 
I am replace <clientname> with the organizationname i am storing in cmb,

Do i have to change any settings in access to enable data types it is access version 2003

LVL 2
mivbinfotechAsked:
Who is Participating?
 
GrahamSkanRetiredCommented:
I'm sorry. I missed the fact that you were running from an application external to Word.

You will need to set a reference to the Microsoft Word Object Library in Tools/References. Also, to avoid possible ambiguities, it would be better to specify the particular object model in the declarations.

Sub ChangeFootNotes()
    Dim rng As Word.Range
    Dim FTNT As Word.Footnote
    Dim i As Integer
    Dim c As Integer
    Dim r As Integer

0
 
mivbinfotechAuthor Commented:
I also tried replacing the footer

  With MDImain.WordApp.Range.Sections(0).Footers(wdHeaderFooterPrimary).Range.Find
        .Text = "<clientname>"
        .Replacement.Text = cmb_organizationName
        .Wrap = wdFindContinue
        .Execute Replace:=wdReplaceAll
    End With

does give object required on first line, not sure what i am doing wrong

0
 
GrahamSkanRetiredCommented:
Hello,
Note that a footer and a footnote are very different things. The only commonality is that they appear at or near the bottom of a page.

It isn't clear what difficulty you are having. I have tweaked your code in order to fill in some of the unspecified variables and data, but it seems to work OK.
Sub ChangeFootNotes()
    Dim rng As Range
    Dim FTNT As Footnote
    Dim i As Integer
    Dim c As Integer
    Dim r As Integer
    
    Const cmb_organizationName = "Some Organisation"
    i = 0
    c = 0
    r = 0
     
    For Each FTNT In ActiveDocument.Footnotes
     
        Set rng = FTNT.Range
       
        i = i + 1
       
        With rng.Find
            .Text = "<clientname>"
            .MatchWildcards = False
            .Replacement.Text = cmb_organizationName
            .Execute Replace:=wdReplaceAll
        End With
     
    Next
End Sub

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
mivbinfotechAuthor Commented:
The point is it gives an error as soon as it comes to

Dim FNT as FootNote

It says object not defined. I try to type and I don't see any data type as footnote.


0
 
mivbinfotechAuthor Commented:
it still gives error user-defined type not defined.

0
 
mivbinfotechAuthor Commented:
i am having trouble adding the reference, which dll shall i add for the reference.
0
 
mivbinfotechAuthor Commented:
i am using access 2007, but i want to be able to use woith access 2003 and office 2003 as well.
0
 
GrahamSkanRetiredCommented:
Add a reference to the 'Microsoft Word Object Library'
0
 
mivbinfotechAuthor Commented:
ok it seems to be working now, now if i put the database into other pcs, will the rereference effect in anyway.

please advise
0
 
GrahamSkanRetiredCommented:
I'm not sure that I understand the new question. Can you explain further, please?
0
 
mivbinfotechAuthor Commented:
Oh ok, I am going to put this application on the network, does it effect is the server this app is put on, does not have ms office installed, all pcs will have ms office installed though, does adding a reference, effect in anyway, to deployment scenario.
0
 
GrahamSkanRetiredCommented:
If it is run on the PCs it won't matter that the server doesn't have Office.
0
 
mivbinfotechAuthor Commented:
Works perfectly fine
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.