#1
|
|||
|
|||
Error on macro to insert endnotes on Mac
I use Word 14.2.3 for Mac under OS X 10.7.5 (Lion). I want a macro that inserts an endnote into a Word document, using Arabic numbering. I recorded such a macro, but when I run it keep getting Run-time error '4605' .
Help, anyone? Here is the code: Code:
Sub InsertEndnote() ' ' InsertEndnote Macro ' ' With Selection With .EndnoteOptions .Location = wdEndOfDocument .NumberingRule = wdRestartContinuous .StartingNumber = 1 .NumberStyle = wdNoteNumberStyleArabic End With .Endnotes.Add Range:=Selection.Range, Reference:="" End With End Sub Last edited by macropod; 12-13-2012 at 05:54 PM. Reason: Added code tags & formatting |
#2
|
||||
|
||||
Hi mbk,
That error suggests you're trying to run the macro when the selection is somewhere other than in the body of the document (eg a textbox, header or footer - where you can't insert an endnote). What does the rest of the error message say?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Error message meaningless
Dear Paul:
Thanks for your prompt reply. The full error message is as follows. Text in < > is comment from me. ------------------------------------------------ Run-time error '4605': The Continue <Greyed-out button> End Debug Help -------------------------------------------------- This error occurs independent of where the focus (cursor) is. It happens at the beginning, in the middle and at the end of text, or in a new blank document. I do not use headers or footers in documents. However, when I create a header and put the cursor in the header the error message runs: ------------------------------------------------ Run-time error '4605': This method or property is not available because the object refers to a header or footer. Continue <Greyed-out button> End Debug Help -------------------------------------------------- So being in a header does make a difference. |
#4
|
||||
|
||||
Hi mbk,
Using your code in Word 2003 and 2010, I'm unable to reproduce a run-time 4605 error unless the selection is somewhere other than where an endnote legitimately can be inserted. The absence of some descriptive text in the first error message is disconcerting - and it makes troubleshooting rather difficult. I've tweaked the code somewhat, but I'm not sure that'll resolve the problem: Code:
Sub InsertEndnote() With Selection If .StoryType <> wdMainTextStory Then Exit Sub .Start = .Words.Last.Start .End = .Words.Last.End If .Characters.Last = " " Then .End = .End - 1 .Collapse wdCollapseEnd .Endnotes.Add Range:=.Range With .EndnoteOptions If .Location <> wdEndOfDocument Then .Location = wdEndOfDocument If .NumberingRule <> wdRestartContinuous Then .NumberingRule = wdRestartContinuous If .StartingNumber <> 1 Then .StartingNumber = 1 If .NumberStyle <> wdNoteNumberStyleArabic Then .NumberStyle = wdNoteNumberStyleArabic End With End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Is it a Mac problem?
Dear Paul:
You said the code runs OK in Word 2003 and 2010. Is that on a Windows PC? Note that I use Word 2011 on an Apple Mac! It does not use Windows but the Apple OS X operating system, release 10.7.5. So the problem may be a Mac vs Windows problem. On my Mac your code produces the same error as my code, but before that your code does insert an endnote, with Roman numbering (i ii iii iv). However, that does not help me. I already have a shortcut for endnotes numbered i, ii, ii. What I need is endnotes numbered 1 2 3, i.e. Arabic numbering. |
#6
|
||||
|
||||
Hi mbk,
Yes, I'm using Word on a PC, which is why I mentioned the versions. The fact you're now getting the endnote shows that the problem isn't in its insertion, but with the code that sets its numbering format. Within the 'With .EndnoteOptions' ... 'End With' block are four code lines. What we need to do is to find which one causes the error. Try commenting-out each line in turn to see whether the code will run withjust one line commented-out. If so, that's the problem line and we might be able to do something with that.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
All 4 lines produce error message
Dear Paul:
I have put a Comment sign <' > before all 4 lines in that block of code. That produced an endnote with roman number, and NO error message. I then reactivated each line separately. When any of the 4 lines was activated I got an endnote with roman number AND an error message. So did various other macros that I created to insert foot- or endnotes. I repeated the whole rigmarole in Word 2003 under XP and everything runs without a hatch. This looks like a problem of Word 2011 for Apple Mac! PS: I also did it according to your literal instructions: comment out one line and leave the other 3 active. Same result for all 4 lines |
#8
|
||||
|
||||
Do you have the same problem if you run the macro in a new document? If it works in a new document, that suggests some corruption in the existing document.
If it doesn't work in a new document, do you have a colleague who has a Mac with Word 2011 so that you could try the macro on that as well? If it works there on a new document, that suggests a fault with your Word installation. If not, it points to a bug in Mac Word.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#9
|
|||
|
|||
Dear Paul:
My colleague tells me he gets the same runtime error 4605 when he runs this macro. He is a professor of genetics, and highly experienced with computers. So it looks like this is a bug in Mac Word. Could you bring this bug to the attention of your colleagues responsible for Mac Word? And yes, I had the same problem when I ran the macro in a new document. |
#10
|
||||
|
||||
OK, looks like it's a bug in Mac Word vba. I don't have any "colleagues responsible for Mac Word" - I don't even work for MS (never have). However, I can file bug reports.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#11
|
|||
|
|||
Thanks for your help!
Dear Paul:
I thought 'MS MVP' was an official function related to Microsoft. I owe you all the more thanks for the time and attention you spent on this. Could you do one last thing and tell Microsoft about this? They might take your report more seriously than mine. Thanks again for your help! mbk |
#12
|
||||
|
||||
Re the MS MVP designation, see: http://mvp.support.microsoft.com/default.aspx and http://www.mvps.org/about/
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Tags |
footnote, macro vba word, record |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to convert endnotes in a text doc to Word endnotes? | Dickison | Word VBA | 4 | 10-06-2012 09:11 PM |
Macro to insert new page... | samanthaj | Word | 17 | 01-31-2012 01:53 PM |
Powerpoint Macro To Insert Objects Sample | lahuva | PowerPoint | 0 | 07-06-2011 10:51 AM |
Insert Page Error | nmbrown | Word | 1 | 10-28-2010 10:33 AM |
Macro for Picture Insert | rfhall50 | Word VBA | 2 | 10-25-2010 12:41 PM |