Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Caption Definition
Hi,
can any body tell me how i can move a caption definition to another template then normal.dot using Word 2003 ? I need this to generate a template for my colleges with some special captions. Thanx Horst |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Caption Definition
Hi Host
In Word 2003, all caption label definitions are saved in normal.dot. That's just how Word is, and you can't change that. If you want your colleague to use your document, your colleague will need to set up a caption definition exactly as you have done. Or, you could run a macro something like the following to do it. If you're not sure what to do with the macro, see Graham Mayor's Idiots' Guide to Installing Macros at http://www.gmayor.com/installing_macro.htm Sub AddCaptionLabel() 'Change this line to use your label name Const csLabelName As String = "MyLabel" Dim oCaptionLabel As Word.CaptionLabel With Word.Application On Error Resume Next Set oCaptionLabel = .CaptionLabels(csLabelName) On Error GoTo 0 If oCaptionLabel Is Nothing Then 'We need to create a new label Set oCaptionLabel = .CaptionLabels _ .Add(Name:=csLabelName) With oCaptionLabel 'Change or delete any of these lines as appropriate .IncludeChapterNumber = False .ChapterStyleLevel = 1 .NumberStyle = wdCaptionNumberStyleArabic .Separator = wdSeparatorPeriod End With End If End With End Sub Hope this helps. Shauna Kelly. Microsoft MVP. http://www.shaunakelly.com/word "hossbear" wrote in message oups.com... Hi, can any body tell me how i can move a caption definition to another template then normal.dot using Word 2003 ? I need this to generate a template for my colleges with some special captions. Thanx Horst |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Caption Definition
Thanx Shauna,
Well that's a pitty that you can't move captions to templates. Will Microsoft ever change this ? Finally I found that I maybe was missusing this feature as i planned to use it for special kind of TOC. So what I did was writing a macro that perfectly does what i want, just based on styles and bookmark. (Linking the macro to a customized toolbar was easy then.) The actual code looks like this Sorry for not following all the code styleguides. ) Sub TOCCite() Dim StyleRange As Range Dim Cnt As Long Dim Cite As String Dim ldBelow As Boolean 'Call a routine that removes any previous settings from the find dialog Call ClearFindAndReplaceParameters 'Now call the fix Call FixWildcardBug 'Call it a second time just in case (because the SendKeys statement is notoriously flaky) Call FixWildcardBug ldBelow = False Cnt = 1 Set StyleRange = ActiveDocument.Range 'check if there is allready such a TOC If ActiveDocument.Bookmarks.Exists("TOCCite") = True Then ActiveDocument.Bookmarks("TOCCite").Range.Select End If Selection.Delete 'Insert the Headline Selection.InsertBefore "Table of References" & vbCr Selection.Style = "TOCHeading" With StyleRange.Find Do .ClearFormatting .Format = True .Wrap = wdFindStop .Style = "Cite" .Execute If .Found Then Cite = "Cite" & CStr(Cnt) 'check if bookmark exists If ActiveDocument.Bookmarks.Exists(Cite) = True Then ActiveDocument.Bookmarks(Cite).Delete End If ' create a new one based on the search result ActiveDocument.Bookmarks.Add Range:=StyleRange, Name:=Cite 'insert txt Cross reference Selection.Collapse Direction:=wdCollapseEnd Selection.InsertCrossReference ReferenceItem:=Cite, _ ReferenceType:=wdRefTypeBookmark, _ ReferenceKind:=wdContentText, _ InsertAsHyperlink:=True, _ IncludePosition:=ldBelow Selection.InsertAfter vbTab Selection.Collapse Direction:=wdCollapseEnd 'insert pge cross reference Selection.InsertCrossReference ReferenceItem:=Cite, _ ReferenceType:=wdRefTypeBookmark, _ ReferenceKind:=wdPageNumber, _ InsertAsHyperlink:=True, _ IncludePosition:=ldBelow Selection.InsertAfter vbCr Selection.Expand Unit:=wdParagraph Selection.Style = "TOCCite" Selection.Collapse Direction:=wdCollapseEnd Cnt = Cnt + 1 End If Loop Until Not .Found End With ' Another time calling the fixes that's really important Call ClearFindAndReplaceParameters Call FixWildcardBug ' wrap the whole thing into a section Selection.InsertAfter vbCr Selection.Style = wdStyleNormal Selection.Collapse Direction:=wdCollapseEnd Selection.InsertBreak Type:=wdSectionBreakNextPage Selection.Expand Unit:=wdParagraph ' put a new chapter underneath if neccesary If Selection.Style "Heading 1" And Selection.Style "TOCHeading" Then Selection.InsertAfter vbCr Selection.Style = wdStyleHeading1 End If ' store the whole thing in a bookmark for later retrieval Selection.Move Unit:=wdParagraph, Count:=-2 Selection.Expand Unit:=wdSection If ActiveDocument.Bookmarks.Exists("TOCCite") = True Then ActiveDocument.Bookmarks("TOCCite").Delete End If ActiveDocument.Bookmarks.Add Range:=Selection, Name:="TOCCite" 'as we might have changed the pages in the meantime Selection.Fields.Update End Sub Unfortunately sometimes this find-bug still escapes out of its box, but then only making all entries twice. Without the fixes installed it sometimes ended up in an endless loop. Thanx for your help Shauna Kelly schrieb: Hi Host In Word 2003, all caption label definitions are saved in normal.dot. That's just how Word is, and you can't change that. If you want your colleague to use your document, your colleague will need to set up a caption definition exactly as you have done. Or, you could run a macro something like the following to do it. If you're not sure what to do with the macro, see Graham Mayor's Idiots' Guide to Installing Macros at http://www.gmayor.com/installing_macro.htm Sub AddCaptionLabel() 'Change this line to use your label name Const csLabelName As String = "MyLabel" Dim oCaptionLabel As Word.CaptionLabel With Word.Application On Error Resume Next Set oCaptionLabel = .CaptionLabels(csLabelName) On Error GoTo 0 If oCaptionLabel Is Nothing Then 'We need to create a new label Set oCaptionLabel = .CaptionLabels _ .Add(Name:=csLabelName) With oCaptionLabel 'Change or delete any of these lines as appropriate .IncludeChapterNumber = False .ChapterStyleLevel = 1 .NumberStyle = wdCaptionNumberStyleArabic .Separator = wdSeparatorPeriod End With End If End With End Sub Hope this helps. Shauna Kelly. Microsoft MVP. http://www.shaunakelly.com/word "hossbear" wrote in message oups.com... Hi, can any body tell me how i can move a caption definition to another template then normal.dot using Word 2003 ? I need this to generate a template for my colleges with some special captions. Thanx Horst |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Is possible to use different caption formats in the same document? | Microsoft Word Help | |||
New caption labels saving | Microsoft Word Help | |||
Auto-insert numbering when caption style applied | Microsoft Word Help | |||
How to hide caption numbers ? | Microsoft Word Help | |||
Image caption chapter # STYLEREF keeps reseting itself after editi | Page Layout |