Wrox Programmer Forums
|
Word VBA Discuss using VBA to program Word.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Word VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 21st, 2011, 09:21 AM
Authorized User
 
Join Date: May 2011
Posts: 44
Thanks: 7
Thanked 0 Times in 0 Posts
Exclamation numbering

Hi,

I have been entering data through the use of bookmarks. During this process I apply the standard word styles.

However, I also want to apply a numbering style (1, 1.1, 1.2, 2, 2.1, etc) to the paragraphs. I know I can just go up to the ribbon and apply it that way but I would really like it to be automated using VBA.

Is this possible?

Thanks

Last edited by cjcant; June 24th, 2011 at 06:06 AM..
 
Old June 22nd, 2011, 01:19 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

Are you applying the heading style or the normal paragraph style?

Try for the options in Selection.Range.ListFormat.

This can help you

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
 
Old June 22nd, 2011, 04:12 AM
Authorized User
 
Join Date: May 2011
Posts: 44
Thanks: 7
Thanked 0 Times in 0 Posts
Default

Hi,

Both, I want to make a report so that there are different levels of headings (heading style) and then body text (normal paragraph style). Numbering for the style are as follows:
heading style 1 = 1, 2, 3
heading style 2 = 1.1, 1.2, 2.1, 2.2
paragraph style = no number

These will then be put into a table of contents (hence why I am using Word's built in styles).

Quote:
Try for the options in Selection.Range.ListFormat.
I am fairly new to VBA and I do not know how this can know that the selection is the bookmark. Also, I have been looking on the internet and I got the impression that you need to know the name of the specific list style. If so what is the name of the above style (it is just a standard Word list style).

Also, it is to be applied to the whole document (if that is easier to do).

Thanks
Christine

P.S. I think I am closer to the selection code but I cannot quite get it right. This is what I have come up with so far:
Code:
Private Sub btnFormat2_Click()

Range("para1").Select
Selection.range.ListFormat.ApplyListTemplateWithLevel(listTemplate, level1)

End Sub

Last edited by cjcant; June 23rd, 2011 at 05:21 AM.. Reason: developments have occured





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with numbering using XSLT worlebird XSLT 8 February 11th, 2010 05:08 AM
Numbering - For each Navy1991_1 XSLT 3 July 2nd, 2008 07:56 AM
Numbering in XSLT Angel1221 XSLT 1 June 10th, 2008 05:07 PM
numbering harag XSLT 2 November 6th, 2003 06:04 AM
XSL numbering be782524 XSLT 2 August 5th, 2003 05:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.