PDA

View Full Version : Format Custom Table of Contents



sheeeng
06-29-2005, 07:02 PM
Hi all :hi:

I'm wondering whether that the TOC of Word can be customize to custom setting. Be it by macro or manually...

The default is
Heading 1
Heading 2
Heading 3

But I need to customize it to
Heading 1
'New Line
Heading 2
'New Line
Heading 3

Please Help. Thx. :friends:

Killian
06-30-2005, 01:09 AM
If you use the default styles (TOC1, TOC2, TOC3) for headings 1 to 3 you can just modify those styles to reflect your preference (double line spacing)

fumei
06-30-2005, 08:52 AM
Yes, and is a EXCELLENT demostration of the proper use of Styles.

If we get you right, what you are really wanting (and correct us if we are wrong), is:

Heading 1
space between thse lines
Heading 2
space between thse lines
Heading 3


If this is correct, then I will safely bet that you put in "extra" Enter keys between paragraphs to make the spaces look proper.

You do not ned this. if the style of the paragraph has that space defined within it...then every instance of that style, will have that space.

MOS MASTER
06-30-2005, 09:41 AM
Agreed changing the style is the apropriate method.

Sheeeng, do you no how to do this? (Change a style)
If not tell us your Word version because the style dialog varies between versions. (So we can tell you how)

Later. :whistle:

fumei
06-30-2005, 10:18 AM
Yes...it changes a bit between versions, but it all of them it is not that hard. So, sheeng, let us know what version, and we can walk you through changes the styles to get your spaces - if that is what you actually want.

MOS MASTER
06-30-2005, 10:24 AM
The bit between 2000 and 2002 is more of a gap! :rofl:

fumei
06-30-2005, 10:28 AM
man, you are so fussy. :friends:

:hi:

MOS MASTER
06-30-2005, 10:35 AM
man, you are so fussy. :friends:

:hi:
Whahaha....sorry Gerry! :neener: :friends: (you no I really can't help myself...)

sheeeng
06-30-2005, 07:59 PM
I'm using many versions. 2000, 2002, 2003.

But primarily is Word 2003. Can anyone customize TOC in VBA macro?

Possible to do?

MOS MASTER
07-01-2005, 09:46 AM
I'm using many versions. 2000, 2002, 2003.

But primarily is Word 2003. Can anyone customize TOC in VBA macro?

Possible to do?
Yes its possible but TOC's are bound to styles and if we don't know which styles you're using then it won't be so easy to write you some code...

This should do what you want:
Sub CustomToc()
With ActiveDocument
.Styles("TOC 1").ParagraphFormat.LineSpacingRule = wdLineSpaceDouble
.Styles("TOC 2").ParagraphFormat.LineSpacingRule = wdLineSpaceDouble
'Add more modifications
.TablesOfContents.Add Range:=Selection.Range
.TablesOfContents(1).TabLeader = wdTabLeaderDots
.TablesOfContents.Format = wdIndexIndent
End With
End Sub


Later :whistle:

sheeeng
07-03-2005, 08:18 AM
Yes its possible but TOC's are bound to styles and if we don't know which styles you're using then it won't be so easy to write you some code...

This should do what you want:
Sub CustomToc()
With ActiveDocument
.Styles("TOC 1").ParagraphFormat.LineSpacingRule = wdLineSpaceDouble
.Styles("TOC 2").ParagraphFormat.LineSpacingRule = wdLineSpaceDouble
'Add more modifications
.TablesOfContents.Add Range:=Selection.Range
.TablesOfContents(1).TabLeader = wdTabLeaderDots
.TablesOfContents.Format = wdIndexIndent
End With
End Sub


Later :whistle:

Could I have the links to more information bout this custom TOC macro code?
This is because i need to customize TOC in different styles...
Thx.:friends:

MOS MASTER
07-03-2005, 08:20 AM
Could I have the links to more information bout this custom TOC macro code?

Links to more information? I have no idea what your talking about.

To change a style used in the Toc use the name of the style the way I used it. :whistle:

sheeeng
07-03-2005, 08:30 AM
Links to more information? I have no idea what your talking about.

To change a style used in the Toc use the name of the style the way I used it. :whistle:

Sorry for my poor english...
What I mean is any internet links to more information on this?
Thx. :friends:

MOS MASTER
07-03-2005, 08:33 AM
Sorry for my poor english...
What I mean is any internet links to more information on this?
Thx. :friends:
Ah Ok..no there's little on this subject to find I think.

I code it manually so I wouldn't know where resources are. I think you have to search google.

:whistle:

sheeeng
07-03-2005, 08:38 AM
Ah Ok..no there's little on this subject to find I think.

I code it manually so I wouldn't know where resources are. I think you have to search google.

:whistle:

Thx, Joost.
You are very helpful. :friends:
Great of having you around..
Well, I'll wait for others for answers.
Thx. :friends:

MOS MASTER
07-03-2005, 08:43 AM
Ok no problem.

But you should better ask specific problems cause the answers to those are possible.

There is a lot of documentation available on the Inet but little of it is general purpose. (In VBA little is general purpose)

The Word object model is difficult so you need to address each specic problem as its own normally.

So if you have a specific problem I'm there to assist! :thumb

sheeeng
07-03-2005, 09:13 AM
Ok no problem.

But you should better ask specific problems cause the answers to those are possible.

There is a lot of documentation available on the Inet but little of it is general purpose. (In VBA little is general purpose)

The Word object model is difficult so you need to address each specic problem as its own normally.

So if you have a specific problem I'm there to assist! :thumb

Thx :friends:

fumei
07-04-2005, 08:09 AM
sheeeng, hmmmm.....OK, you have to learn some of hpw Word is truly designed.

Some one could argue, and I am willing to listen, but I will state categorically that Word is designed around styles. It is literally impossible to have a paragraph that is NOT a style. Therefore, to understand Word (or at least some of it), you need to grasp styles. Not just for this exercise, but generally.

As Joost stated, generated ToC are bound to a style. You may bind a ToC level to any style you wish. Conclusion? Hmmmm, if I want to really control my ToC....I had better design and create my own ToC styles.

This is where I have to disagree with Joost's post. His code modifies the existing TOC style. I do not think this is, in the long run a proper strategy. This is even more of an issue if you want to be able to have different ToC format or structure.

Make you own ToC styles; use them in proper templates.

MOS MASTER
07-04-2005, 08:29 AM
This is where I have to disagree with Joost's post. His code modifies the existing TOC style. I do not think this is, in the long run a proper strategy. This is even more of an issue if you want to be able to have different ToC format or structure.

Hi Gerry, :yes

As usual we are not in disagreement!

My post was the exact answer to the original post. (Got no feedback if it worked however..it does here)

I also said before this shouldn't be done by code but with a proper templates with styles. (Or modify existing TOC styles)

So...No we agree very much...but Sheeeng wanted a code example so he got one...:whistle:

Killian
07-04-2005, 08:30 AM
Some one could argue, and I am willing to listen, but I will state categorically that Word is designed around styles.I can't imagine anyone arguing with that.

MOS MASTER
07-04-2005, 08:31 AM
I can't imagine anyone arguing with that.
Me neither...:rofl:

fumei
07-04-2005, 08:44 AM
Ah, actually, am I have another stupid day? I am not thinking anyone IS arguing. Wait....well...I guess I am.

Joost, technically speaking, and since this IS a technical forum to an extent, the original post asked about customizing the ToC. It did NOT ask about customizing the existing ToC styles - which is what your code does.

True, modifying the existing ToC styles modifies the ToC when those styles are used to generate a ToC. However, that is a result. The core point is that, as stated, ToC are bound to a style, and........wait for it....it is general good practice that if you need a different format for text, you make a different style.

This is especially true IMHO when you using code. Modifying styles dynamically can be done for sure, but frankly, I do not use it that way. I use the styles property more as a searching tool.

Also, changing the existing ToC styles affects things globally. Say you change the ToC, and your code would have done it to normal.dot. Any other documents that are opened, and the ToC refreshed (because you add another chunk of text say). Your code will change that document. This may(or it may not!) be what is required.

So, IMHO the post should be answered - as you did - it depends.

GOOD MORNING!

MOS MASTER
07-04-2005, 08:52 AM
Hahhaa, :yes

Well Gerry it's evening over here...

Have you tried my code?
You talk about changing things globally? No not really.
I'm changing the TOC styles for that document and not the Mama (Normal)....

So please try my code and see if it changes your Normal.dot...:whistle:

fumei
07-04-2005, 10:35 AM
I am signing off. I am clearly of no use at all today. Stupid day, stupid day....me, me, me..having stupid day.

sheeeng
07-04-2005, 06:17 PM
Hi Gerry, :yes

As usual we are not in disagreement!

My post was the exact answer to the original post. (Got no feedback if it worked however..it does here)

I also said before this shouldn't be done by code but with a proper templates with styles. (Or modify existing TOC styles)

So...No we agree very much...but Sheeeng wanted a code example so he got one...:whistle:

Please don't argue...I hope my started thread here is not to tear down this forum...:friends:

On the codes, pls give me some time to try it out. I'm kinda busy this week on work.:doh:

Hope everyone here can help each other in VBA.:friends:

Good day to all.:hi:

MOS MASTER
07-05-2005, 10:49 AM
Hi Sheeeng, :yes

No worries, AFAIK Gerry & I don't argue!

For me this is called a discussion between two Word lovers sharing knowledge.

My main reasson for posting on forums is to discuss my favorite app with other experts and to share and add to the diversity of sollutions. (Helping others in the process is a benefit not the main purpose)

Perhaps Gerry has a different point of view, but he knows I have a very high opinion of him! :bow:

Later..:whistle:

sheeeng
07-05-2005, 07:09 PM
Ok no problem.

But you should better ask specific problems cause the answers to those are possible.

There is a lot of documentation available on the Inet but little of it is general purpose. (In VBA little is general purpose)

The Word object model is difficult so you need to address each specic problem as its own normally.

So if you have a specific problem I'm there to assist! :thumb

Is Inet = Internet? I wondered that for long till now....:doh:

MOS MASTER
07-06-2005, 11:58 AM
Is Inet = Internet? I wondered that for long till now....:doh:
Yeps..I always call it Inet others wil call it .NET or other terms but indeed I mean the World Wide Web. :whistle:

fumei
07-06-2005, 11:35 PM
Joost and I have a very good relationship. We are definitely not arguing. Or if we were, we would take it off-forum and communicate directly. Which we do. I enjoy his banter immensely, and respect his knowedge hugely. He catches my errors rather nicely, and it is a bad coder that does not appreciate error being caught. Joost keeps me humble. That being said.....

Inet = World Wide Web?

Bah. Nonsense! Pooooohie! There was a viable Internet years before the World Wide Web existed. You young people....

:razz2:

MOS MASTER
07-08-2005, 09:18 AM
Hi Gerry, :yes

Glad where on the same page and you keep me humble as well!....That being said...

Blah, blah blah..Yes us young people have not been on the Inet for long and as long as I can remember the Inet for me is the ?WWW? .... I was probably still in diapers when you made your first surf! (On your viable .Net).....

Tada...:goofball:

sheeeng
07-10-2005, 05:42 AM
Joost and I have a very good relationship. We are definitely not arguing. Or if we were, we would take it off-forum and communicate directly. Which we do. I enjoy his banter immensely, and respect his knowedge hugely. He catches my errors rather nicely, and it is a bad coder that does not appreciate error being caught. Joost keeps me humble. That being said.....

Inet = World Wide Web?

Bah. Nonsense! Pooooohie! There was a viable Internet years before the World Wide Web existed. You young people....

:razz2:

Thx for informing me...
I'm in my diapers at that time...:giggle

MOS MASTER
07-10-2005, 05:46 AM
Thx for informing me...
I'm in my diapers at that time...:giggle

Me too...:rofl:

Scottie P
07-10-2005, 08:30 AM
Gerry is one of us from the 'handset cradle-modem' days...:winking2:

MOS MASTER
07-10-2005, 10:17 AM
Gerry is one of us from the 'handset cradle-modem' days...:winking2:
Ah ok now I remember seeing one of those in the museum.

Wasn't it a great black box with big flashing transistors? :rofl: (didn't you have to feed those with punch cards??)

Scottie P
07-10-2005, 10:31 AM
The cradle I remember was a flesh-tone colour - similar to that of the default userform background color - in the shape of a tissue box (and nearly the same size!). A big red light let you know that the modem was engaged/conected. The handset of a telephone set into the cradle.

Sometimes it took 20 minutes of dialing to get connected; other times it was the first dial that hooked up. It was difficult to know whether you had a connection because if the modem line was open (but not connected) that big red light stayed lit anyway. LOL!
Yes, cards. It was always difficult when they were not in proper order. We used to save them in a shoe box with dividers fashioned from other pieces of cardboard or white index (recipe) cards.
It was cutting edge technology! I remember learning my first Basic program - coin flip - the probability of heads or tails per number of flips. I also remember other, more complicated programs for calculation and missing a line...so you would have to go back and try to find the missing numeric designate - no Error #s or Msgboxes then! LOL!

It was an interesting thing though...then the little Apple Computers came - no one could believe that they were capable of even more functionality than the those giant CPUs that we were tapping into at the time. I cannot remember the modem type for those machines nor when I first saw a desktop modem, with a connection that only required a phone line...and no more handset...probably within the same year or 2 as those little Apple machines.

**EDIT**

I found an image of one - this one is slightly more modern than what we had originally: modem image (http://www.michie.net/images/modem1.jpg) The image is a bit small but I think you can make out the details.

MOS MASTER
07-10-2005, 10:59 AM
I found an image of one - this one is slightly more modern than what we had originally: modem image (http://www.michie.net/images/modem1.jpg) The image is a bit small but I think you can make out the details.

Yes for sure that's the one from the museum. :hi: (Never had the pleasure of operating one)

fumei
07-10-2005, 09:11 PM
Wow Scott...where did you find that? I remember punch cards all too well.

Listen you youngin's, back in the dark days of DOS (and pre 4.0, the evil spawn laughably an OS) we used to build PC's, and I mean actually put circuit chips on the motherboard, adding power supplies, cabling...BUILD them, blindfolded...just for fun. Putting them together by FEEL. In the dark. This was what we did in the spare time we had running "real" computers. Hulking mainframes.

Scott sounds old enough to remember the joys of Archie and Veronica.

Hate to tell you this, but unless things are changed (which they may have...I am getting senile), your mail is STILL not using www. Your mail, is going SMTP, its own protocol and is NOT on the World Wide Web - technically speaking, although it IS on the Internet. Why?

Because the Internet is NOT the world wide web. The Internet is the routing...hmmm, mechanism is not quite the word. However, call it a mechanism.

Saying the Internet is the world wide web, is the same as calling your dashboard dials and lights - the car. Well, it is not the car, it is the graphical interface (and only one of) you have with the car.

One of the concerns I have actually, is that the backbone, the guts of this thing - the Internet - is disappearing from consciousness. Most people now think as you do Joost. There it is, the Web. That is it, and getting bigger and better.

Back then, we had some real say and control of how things worked. Now, we have nothing except prettier pictures and Flash.

Oh well, things were doomed when TCP/IP became standard. But...at least we can enjoy the show. Bread and circuses.

Scottie P
07-10-2005, 09:24 PM
Gerry, my first build was PC based pair of 8088s with a 640 KB harddrive <- this is not a typo! 640 kb was really something to have! We had those 'place mat' sized 5.25" floppy discs (that I am sure MOS MASTER also saw in the museum) and Gerry is not joking about taking up a soldering iron and going to work on a motherboard - not by any stretch. Radio Shack was abundant in 'off the shelf' components in those days, so everyone was doing mods, hardwiring external modems, and attempting to gang those 8088 chips. All of this was before 286 series.

When 286 hit the streets we were in heaven...but 386 came quickly after. Most home users with a little electronics know-how were modding there 286 systems to take the 386 series.

Oh, and RAM? LOL! 8 Meg was screamin - and very expensive (if you had slots for it).

**EDIT**

Oh and CGA monitors!

fumei
07-10-2005, 09:34 PM
I bought a 286 when they first came out. I think I was the first in town. I was a rooster... strutting...it had 16 Mb of RAM!

We had that thing stripped to parts, and rebuilt again, the first night. Just HAD TO see that CPU!

Now I look in our AIX box - 128 (yes, 128) 3.0 GHz Xeon processors...shrug my shoulders and yawn. However, if they would just let me run POVRay on it......then I would be a kid again. Can you imagine?

fumei
07-10-2005, 09:38 PM
Oh (roll of the eyes....) CGA. Hey Scott, explain CGA to these guys.

You know, I still have a copy of the original Sokoban...in living CGA! And a VAX compile (ported to DOS) of Empire - not that Microsoft thingie people. The original Empire that actually shut down the Berkeley computer because nerds were playing it so much. The one we were playing before Bill Gates touched a computer.

Man, I need a nap.

Scottie P
07-10-2005, 09:50 PM
Our access to programs was pretty limited - our group was small and local and no one was a currently enrolled student so program stuff was hard to come by.
I think 'Kroz' was our game (addiction) of choice at the time and what was that Shell Doctor program...Dr Dos or PC Doctor or something? I just can't remember anymore. I really had little interest in software though (except for that Kroz game); I loved tinkering with hardware - I had a 10'x10' room full of parts, monitors, case skeletons...parts. LOL!

CGA - Black and White...LOL! What a color variety - that is what I had first. Then I upgraded to one that was Orange and Black. I cannot remember what I had before the VGA (which is nothing like todays VGA)...but I was able to get about 8 colors...Cyan, Magenta, Yellow, Green, Red, Black, White and...was it dark Blue Gerry? And what was that - it wasn't VGA yet. Was that the EGA??

Oh man, a trip down memory lane or a taste of hell...what is this thread!? LOL!!

Scottie P
07-10-2005, 10:02 PM
We need our own forum for this stuff - the good ole days of computing or something!

I remember being in NY and visiting friends; the wife was a distribution associate for Microsoft! I had everything first run; I had a box full of Beta stuff from MS, I had full versions of Harvard Graphics and Word Perfect as well (I think that MS was doing side by side comparisons of WP vs Word at the time so I ended up with WP as well).
Anyway, one weekend we were visiting and went out - it was either Egghead or Circuit City...they were having some sort of promotion and they were giving away - FOR FREE - DOS 6.2 Upgrades!!! Can you imagine Gerry!!?? DOD 6.2 - FOR FREE!!! I grabbed a bunch of them and to this day I can still see the sleeve art on the packaging! LOL!

I don't remember much of Excel 4 (I have had this conversation with Bill Jelen)...but I do remember the first time I saw Windows...man what a thing that was to lay eyes on.

My apologies to Sheeeng - we have overtaken this thread horribly.
Sorry Sheeeng... :(

fumei
07-11-2005, 04:25 AM
That we have. this thread is totally hijacked.

Remember Windows 286? Lordy lordy lordy. I think I actually go back farther than you. Pre 8088 I'm afraid.

CGA monitors most commonly was two tones, but the advanced graphic capability of the new video cards, the real hot new ones with GASP!!!! 8 Mb of video!! gave FOUR colours to CGA.

Just as a further laugh, and a perspective on the object-mess of VBA (since this a VBA forum), I got into a major dust-up with some programmer, because it had taken them 6 weeks to add another item to a dropdown list. MicroFocus Cobol - screen elements are HARD CODED by pixel locations.

Heck of a lot different from: ComboBox1. AddItem

MOS MASTER
07-11-2005, 09:01 AM
Hi Gerry, :yes

Yes of course your right there are many protocols supporting the Internet. And no it's not just the WWW.

Internet means: "International Network" (No I did not look this up) :rofl:

But when I talk about the Internet I only talk about the: "www"...don't know it that's a bad thing. That's my favorite part of the Internet. All those networks and blah, blah..don't do it for me....(Otherwise I would have gone and got me a MCSE Certificate) :rotlaugh:

So yes for me as a youngster I don't have my fact's straight...and I have to live with it. :*)