PDA

View Full Version : Changing the numbering font size



CarlyChemE
11-11-2008, 07:12 AM
Hello, I am new to this forum as well as new to coding in word VBA. This is a part word and part excel question. I am controlling a word document from excel. Before i close the word document i want to reset the font size of the numbering list to 16. In word, the code looks like this:

Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=ListGalleries(wdNumberGallery).ListTemplates(2), ContinuePreviousList:=True, ApplyTo:=wdListApplyToWholeList, DefaultListBehavior:=wdWord10ListBehavior

but when the above code is in excel it gives me an error, even when i put "docword.application" (docword is the variable for the word document) before "selection." The error is:

Run Time Error '462'
The remote server machine does not exist or is unavailable

anyone know how i can fix this?

CarlyChemE
11-11-2008, 07:16 AM
i have also tried:

docword.select
Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=ListGalleries(wdNumberGallery).ListTemplates(2), ContinuePreviousList:=True, ApplyTo:=wdListApplyToWholeList, DefaultListBehavior:=wdWord10ListBehavior

But then i get error

Run Time Error '450'
Wrong number of arguments or invalid property assignment

TonyJollans
11-13-2008, 01:48 PM
The 'remote server' message is usually a result of implicit instantiation somewhere. You must make sure that *all* references to elements of the Word object model are properly qualified - as in your example of qualifying Selection with docword.application.

I guess if you're new to VBA that doesn't mean much to you. Sometimes, when you don't do this, Automation manages to create a new instance of a Word application and/or document; it's only trying to help but it doesn't do it well enough and ends up with pointers to nowhere.

Two other points, briefly, ..

1. Try to avoid using the Selection - especially when using Automation. It's very inefficient.

2. ListTemplates and ListGalleries do not work the way you think they do - whatever you think :). You will not get consistent results from that code.