Thread: [Solved] Bulletted List Creation
View Single Post
 
Old 11-09-2013, 02:03 PM
jdean jdean is offline Windows XP Office 2010 32bit
Novice
 
Join Date: Nov 2013
Posts: 14
jdean is on a distinguished road
Default

Macropod, I really appreciate your code. The problem is that the macro will run on a different instance of Word each time. Basically, the macro is in XL sheet..

1. It creates a new Word document object and then imports data from XL into the Word document. Every part of the code works great, except bulletting and indenting the paragraphs that have those conditions. Further, different people will be running the code on their pcs, so creating two bullet styles - A and B on my pc is not viable.

2. In other words, the 2 styles "BulletA" and "BulletB" must be created via VBA at every instantiation of a new Word object (if the two styles don't exist already for the user) and applied to the targeted paragraphs.


** After taking a stab at recording a macro, I was able to come up with something along these lines.

Code:
Dim opara as word.paragraph
'-- Assuming the newly created active doc is MyDoc then I do
For Each oPara In MyDoc.Paragraphs
   if oPara.Range.Words(1).Text="Met" then
     oPara.Range.ListFormat.ApplyListTemplate ListGalleries(wdBulletGallery).ListTemplates(1).ListLevels(1).NumberFormat = ChrW(61623)
  else if oPara.Range.Words(1).Text="Exceeded" then
     oPara.Range.ListFormat.ApplyListTemplate  ListGalleries(wdBulletGallery).ListTemplates(1).ListLevels(1).NumberFormat  = "o"
end if
Next
However, when I run it, I get the RUNTIME ERROR: "424" Object Required, highlighting the lines starting with "oPara.Range.ListFormat.ApplyListTemplate..." in the code

So,I guess it is not recognizing the opara.range as a "range object"? What do I appear to be doing wrong? This stuff has stressed me for a few days now.

Thanks!
Jay
Reply With Quote