Access to Word - Naming Sections For Use
Access to Word - Naming Sections For Use
(OP)
is there a way to add a "description" to a section in VBA so that I can reference it when coding? so if I insert a new section I don't have to adjust all my section call outs
currently I'm creating a section from Access VBA to Word like so:
I'd like to be able to create the section and reference it like "wd.ActiveDocument.Sections("Header").Range.Font.Size = 11" or something.. I currently have 20 sections and its a pain to go back and update all of them.
currently I'm creating a section from Access VBA to Word like so:
CODE -->
wd.Selection.InsertAfter Text:=vbTab & "TAG #" & vbTab & vbTab & "QTY" & vbTab & "DESCRIPTION" & vbCr wd.ActiveDocument.Sections(1).Range.Font.Size = 11 wd.ActiveDocument.Sections(1).Range.Font.Bold = False wd.ActiveDocument.Sections(1).Range.Font.AllCaps = True wd.ActiveDocument.Sections(1).Range.Font.Underline = False wd.ActiveDocument.Sections(1).Range.Font.Italic = False wd.Selection.Collapse wdCollapseEnd wd.Selection.InsertBreak Type:=wdSectionBreakContinuous wd.Selection.TypeParagraph
I'd like to be able to create the section and reference it like "wd.ActiveDocument.Sections("Header").Range.Font.Size = 11" or something.. I currently have 20 sections and its a pain to go back and update all of them.
RE: Access to Word - Naming Sections For Use
CODE -->
Least this will mean a whole lot less to update,
https://engineervsheep.com
RE: Access to Word - Naming Sections For Use
CODE
and then
CODE
At the start I put in the first bit of code, then my text and what not, then run the second code section... my 'with statement', then put in a section break , then the first code again. I also streamlined it since I got it working how I wanted...
CODE
rinse and repeat.
RE: Access to Word - Naming Sections For Use
Add adds an object to the referenced Collection to
Collection.Count + 1
So that directly AFTER Add, if you were to Count the collection, the Collection.Count would be the Index of the newly added Collection Item.
Collection(Collection.Count)
You can assign a Name to any Collection Item and reference any Collection Item by either Name or Index.
Skip,
Just traded in my OLD subtlety...
for a NUance!