Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to Extract Footnoes in Word to a New Word File

Status
Not open for further replies.

umchemist

Technical User
Feb 25, 2010
5
CA
Hi Everyone,

I have the following code:

<code>
Dim lCount As Long
Dim sEnd As String
Dim oDoc As Document

sEnd = "Endnotes" & vbCrLf
For lCount = 1 To ActiveDocument.Endnotes.Count
sEnd = sEnd & lCount & vbTab &
ActiveDocument.Endnotes(lCount).Range.Text & vbCrLf
Next lCount

sEnd = sEnd & "Footnotes" & vbCrLf
For lCount = 1 To ActiveDocument.Footnotes.Count
sEnd = sEnd & lCount & vbTab &
ActiveDocument.Footnotes(lCount).Range.Text & vbCrLf
Next lCount

Set oDoc = Documents.Add
oDoc.Range.Text = sEnd
</code>

and it is supposed to extract all footnotes and endnotes in a word file into a new file. BUT, I get the following error :
"Compile Error: Invalid Outside Procedure"

Can anyone help me to get this to work ?????

Thanks
 



Hi,

Please post ALL the code in your module.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Its the only macro I have in the word document, stored in Normal/Microsoft Word Objects/ThisDocumen

Sub PullMe()
Dim lCount As Long
Dim sEnd As String
Dim oDoc As Document

sEnd = "Endnotes" & vbCrLf
For lCount = 1 To ActiveDocument.Endnotes.Count
sEnd = sEnd & lCount & vbTab &
ActiveDocument.Endnotes(lCount).Range.Text & vbCrLf
Next lCount

sEnd = sEnd & "Footnotes" & vbCrLf
For lCount = 1 To ActiveDocument.Footnotes.Count
sEnd = sEnd & lCount & vbTab &
ActiveDocument.Footnotes(lCount).Range.Text & vbCrLf
Next lCount

Set oDoc = Documents.Add
oDoc.Range.Text = sEnd

End Sub

 
But not I get a syntax error at:

Code:
sEnd = sEnd & lCount & vbTab &


Anyone have any ideas?
 



Get rid of the trailing ampersand concatenation character.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
No, rather get rid of the line break after that ampersand:

sEnd = sEnd & lCount & vbTab & ActiveDocument.Footnotes(lCount).Range.Text & vbCrLf

;-)

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
You guys are superstars!!!

Thanks so much, worked perfect!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top