![]() |
|
#1
|
|||
|
|||
![]()
In proposals at my job, we cross-reference captions in the text callouts. Captions use the label "Figure" and then auto-numbering, both picked up by the cross-references. However, when the cross-reference word "figure" does not begin a sentence, as in
As shown in figure 3, ... our style is to use the lower-case f. When updating the document (or printing, despite unchecking the relevant links options), the lower case changes back to upper case. My goal is to be able, when the document is final, to remove the links from the cross-references to the captions, so that I can search/replace for the one's that don't start sentences, replacing the F in Figure with f. (It's unusual to have more than 50 such, and this takes me just a few minutes.) Since using Ctrl+A and Ctrl+Shift+F9 also removes the caption and any other hyperlinks in what can sometimes be a very lengthy document, this is not a solution. I'd like to have a macro that can remove only the cross-reference fields for captions. Perhaps it could target caption cross-references; perhaps just the word cross-referenced word Figure. I suspect it could be a fairly simple macro. Help greatly appreciated, as always. |
#2
|
|||
|
|||
![]()
Add a formatting switch:
Code:
Sub ScratchMacro() 'A basic Word macro coded by Greg Maxey, http://gregmaxey.com/word_tips.html, 7/10/2017 Dim oFld As Field For Each oFld In ActiveDocument.Fields If oFld.Type = 3 Then oFld.Select If Not InStr(oFld.Code.Text, "\* Lower") > 0 Then If MsgBox("Format with lower case?", vbQuestion + vbYesNo, "FORMAT") = vbYes Then If InStr(oFld.Code.Text, "\h") > 0 Then oFld.Code.Text = Replace(oFld.Code.Text, "\h", "\* Lower \h") End If oFld.Update End If Else If MsgBox("Format with upper case?", vbQuestion + vbYesNo, "FORMAT") = vbYes Then If InStr(oFld.Code.Text, "\h") > 0 Then oFld.Code.Text = Replace(oFld.Code.Text, "\* Lower \h", "\h") End If oFld.Update End If End If End If Next End Sub lbl_Exit: Exit Sub End Sub |
#3
|
|||
|
|||
![]()
Hi, Greg, and thank you. I am not a coder, though I have recorded some simple macros and managed occasionally to figure out a few very basic edits. I have tried to understand the macro you provided and have looked at the "deleting fields" section on the page you linked from your site, but I'm afraid I am at a loss. I have no idea where I should be adding a format switch to your macro or what it could possibly be. Would you help me out, please?
|
#4
|
|||
|
|||
![]()
Just run the macro on an active document. It loops through the fields, selects the field if it is a REF field and applies or removes a formatting switch \* Lower based on your actions.
|
#5
|
|||
|
|||
![]()
Thank you, Greg. I'm getting an error message, though, saying that only comments can appear after End Sub and a few other End commands. Could those last lines be the culprit?
Again, thanks for your help. |
#6
|
|||
|
|||
![]()
Greg, I tried removing the lines after the first End Sub, and the macro seems to work fine now. Thanks again.
|
![]() |
Tags |
cross-reference, macro, unlink |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
mktate | Word VBA | 7 | 06-24-2016 05:55 AM |
Cross reference is bad. | Leffken | Word | 1 | 06-09-2016 03:12 PM |
![]() |
lonniepoet | Excel Programming | 1 | 06-09-2016 09:54 AM |
![]() |
wmac | Word | 1 | 05-14-2013 08:54 PM |
manipulating cross-reference fields | _wim_ | Word | 0 | 12-10-2010 05:52 AM |