Replace footer in word with excel macro error

hlg0035

New Member
Joined
Sep 8, 2014
Messages
13
Hello all-

I'm trying to replace the footer information in Word with this (see below) and I receive this error: compile error: user-defined type not defined. Any help would be appreciated!

'Replace the footer info
Dim oSection As Word.Section
Dim oRange As Word.Range
Dim Var
For Each oSection In WrdDoc.Sections()
Set oRange = oSection.Footers(Var).Range
oRange.Find.Execute FindText:="[CDAREPDATE]"
Set oRange = Nothing
Next
Next
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
No that doesn't set a Reference. You can't do this with late binding:

Code:
Dim oSection As Word.Section
Dim oRange As Word.Range

try declaring them as Object.
 
Upvote 0
Thank you, this is what I have now:

I am getting an error with the bolded line item now: The requested member of the collection does not exist

Dim oSection As Object
Dim oRange As Object
Dim Var
For Each oSection In WrdDoc.Sections()
Set oRange = oSection.Footers(Var).Range
oRange.Find.Execute FindText:="[CDAREPDATE]"
Set oRange = Nothing
Next


No that doesn't set a Reference. You can't do this with late binding:

Code:
Dim oSection As Word.Section
Dim oRange As Word.Range

try declaring them as Object.
 
Upvote 0

Forum statistics

Threads
1,222,069
Messages
6,163,736
Members
451,854
Latest member
Tiffany Smith

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top