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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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
Acronis Data Cloud 7.8 Enhances Cyber Protection

A closer look at five essential enhancements that benefit end-users and help MSPs take their cloud data protection business further.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.