开发者

generating TableOfContents using Word VBA, siimple VBA method not working properly

开发者 https://www.devze.com 2023-03-20 13:03 出处:网络
I don\'t understand Why t he following function returning \"Nothing\" Public Function generatsTOC(ByRef doc As Word.Document) As Word.TableOfContents

I don't understand Why t he following function returning "Nothing"

Public Function generatsTOC(ByRef doc As Word.Document) As Word.TableOfContents

    Dim toc As Word.TableOfContents

    Set toc = doc.TablesOfContents.Add(range:=doc.range(0, 0), UseHyperlinks:=True, _  
              UseFields:=False, UseHeadingStyles:=True, _
              UpperHeadingLevel:=1, LowerHeadingLevel:=4, IncludePageNumbers:=True, _ 
              RightAlignPageNumbers:=True)

    Set generatesTOC = toc

End Function

In the next class...

dim itoc as word.TableOfContents
dim tcg as TableOfContentsGenerator
set tcg = new TableOfContentsGenerator

Set itoc = tcg.generatsTOC(doc)

When I am 开发者_如何学编程watching itoc, it is NOTHING.

I don't see to figure out how is it not working?


It was the silliest mistake on planet . I resolved the problem by correcting the SPELLING of : generatsTOC >>>> generatesTOC

0

精彩评论

暂无评论...
验证码 换一张
取 消