Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 03-03-2016, 01:56 PM
here4singin here4singin is offline Define custom Cross-reference output format to include "static" text and pg numbers Windows 7 64bit Define custom Cross-reference output format to include "static" text and pg numbers Office 2013
Novice
 
Join Date: Mar 2016
Posts: 2
here4singin is on a distinguished road
Default Need Macro Code

Hi,

I used the macro above to insert a cross reference to heading text with the page number. Thank you for providing this code. Although it inserted the page number after the heading text, it is the current page instead of the cross reference's page number.

I also needed the macro to make the heading text ONLY be a certain character style, and I wanted the Insert As Hyperlink option selected when the dialog opened. My macro needs help. So far, it does this:

1. Opens the Insert Cross Reference dialog with the Insert as Hyperlink check box selected.
2. Lets me choose and insert the heading text I want to display.
3. When I press Close, it changes the whole thing to a character style called Character Hyperlink for Cross References, and it adds a page number in parenthesis.

My problem is with #3. I need only the heading text (not the page number) to be Character Hyperlink for Cross References. I need the rest of the text "(page X)" to be the current paragraph's style (not Character Hyperlink for Cross References). Lastly, I need the page number to go to the correct page (not the current page).

Example: Running with Bears (page 67)

Can you help rewrite this macro? I'm afraid I've reached the limit of my first-time macro user capabilities. I only got this far with help from a developer.

Thank you! Here is my macro so far:

Sub InsertXrefWithPage()
Dim StrNm As String
Dim Dlg As Dialog
Set Dlg = Dialogs(wdDialogInsertCrossReference)
Dlg.InsertAsHyperLink = 1
Dlg.Display
With Selection
Dim CurrentStyle As Style
Set CurrentStyle = .Style
.Start = .Start - 1
.Style = "Character Hyperlink for Cross References"
If .Fields.Count = 0 Then Exit Sub
StrNm = "PAGE" & .Fields(1).Code.Text
.InsertAfter " (page "
.Collapse wdCollapseEnd
Dim addedField As Field
Set addedField = .Fields.Add(Range:=.Range, Type:=wdFieldEmpty, Text:=StrNm, PreserveFormatting:=False)
.InsertAfter ")"
addedField.Select
.Style = CurrentStyle


End With
End Sub

Last edited by here4singin; 03-03-2016 at 01:58 PM. Reason: Woops forgot the macro code
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Define custom Cross-reference output format to include "static" text and pg numbers Add static text to cross-reference tfa91 Word 7 10-09-2019 07:15 AM
Define custom Cross-reference output format to include "static" text and pg numbers Making cross-reference say "Fig." instead of "Figure" dgalb Word 17 11-09-2014 06:25 AM
Define custom Cross-reference output format to include "static" text and pg numbers Reference number and cross reference for equation numbers to match the thesis format wmac Word 1 05-14-2013 08:54 PM
Cross Reference Heading Number with the word "Section" included bblouin Word 5 12-20-2012 05:27 PM
Define custom Cross-reference output format to include "static" text and pg numbers Is there a way to make the cross-refernce format to be "Only lable and number"? Jamal NUMAN Word 1 04-10-2011 03:31 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:04 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft