Skip to main content link. Accesskey S
  • Help
  • HCL Logo
  • HCL Notes and Domino Application Development wiki
  • THIS WIKI IS READ-ONLY. Individual names altered for privacy purposes.
  • HCL Forums and Blogs
  • Home
  • Product Documentation
  • Community Articles
  • Learning Center
  • API Documentation
Search
Community Articles > Programming > HowTo: Create Bullet List in Word Document
  • Share Show Menu▼
  • Subscribe Show Menu▼

Recent articles by this author

Traversing XML result of AJAX request with JQuery

When working with JQuery and Ajax, there is simply no simple good instructions on how to traverse the complete tree of an XML result of an Ajax call. This is how You do it.

A shortcut for get the number of rows used in Excelfile/Worksheet

When working with Excelfiles it is very common to know how many rows there is to process in the file so that You can inform the user in a progressbar or something. I've seen a numerous examples of simple looping through each row until the ActiveCell is a nullvalue (empty string). This is not very ...

How to create and send an email message containing an HTML body using an agent

To create an email that contains a HTML body is a quite simple process, but there is a lot to think about because of the variety of emailclients and their specific behaviour in how they implement the HTMLCSS specifications. I will here try to guide You through the complete steps needed to ...

Using XML response from Ajax call in Lotus Domino Web applications

There is a lot to say when it comes to AJAX! If You have read the article "Integrating Ajax into traditional IBM Lotus Domino Web applications" (http:www-10.lotus.comlddddwiki.nsfdxIntegratingAjaxintotraditionalIBMLotusDominoWebapplications) You will know how to use the Ajax response ...

HowTo: Create Bullet List in Word Document

I'm continuing the discussion on how to create a word document. Now it's time to understand how to format text in Word; This time I'll show how to write Bullet Lists into a word document. First, read up on how to create a word document here: ...
Community articleHowTo: Create Bullet List in Word Document
Added by ~Richard Zekboosilyettu | Edited by ~Richard Zekboosilyettu on July 13, 2010 | Version 4
  • Actions Show Menu▼
expanded Abstract
collapsed Abstract
No abstract provided.
Tags: word, tutorials, programming, app dev

I'm continuing the discussion on how to create a word document. Now it's time to understand how to format text in Word;

This time I'll show how to write Bullet Lists into a word document.

First, read up on how to create a word document here:
http://www-10.lotus.com/ldd/ddwiki.nsf/dx/HowTo_Create_a_Word_Document_from_LotusScript


So, let's start with creating a blank Word document:

Dim objWord As Variant ' Holder for Word (application)
Dim objDoc As Variant ' Holder for the word document
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add() ' The Add() function takes one parameter. See my previous article about this.

Word stores the Bullet lists in what's called as "Galleries" - a couple of predefined ways to display lists in different ways. Therefore we need to retreive the galleries object from wich we will get the desired bullet list:

Dim objListGalleries As Variant ' Holder for the galleries
Set objListGalleries = objWord.Application.ListGalleries

Now, we will need a bunch of CONSTANTS:

 Const wdUndefined = &H98967F
 Const wdTrailingTab = 0
 Const wdListNumberStyleBullet = &H17
 Const wdListLevelAlignLeft = 0
 Const wdListApplyToWholeList = 0
 Const wdWord9ListBehavior = 1
 Const wdNumberParagraph = 1
 Const wdBulletGallery = 1
 Const wdNumberGallery = 2
 Const wdColorAutomatic = &HFF000000
 Const wdColorDarkRed = &H80
 Const wdColorDarkBlue = &H800000
 Const wdLine = 5

Later on, we will need to convert the "Position" to Points, rather than centimeters (if You are using the metric system). I have a function called "CentimetersToPoints()":

Public Function CentimetersToPoints(Byval cm As Single) As Single
 ' 1 cm = 28.35 points
 CentimetersToPoints = (cm * 28.35) 
End Function

You could skip this function and set the positions with point-values directly, but working with centimeters or inches is far easier that points...

Now we can set the gallery with the look and feel of Your choise:

 With objListGalleries(wdBulletGallery).ListTemplates(1).ListLevels(1)
  .NumberFormat = Uchr$(61623)
  .TrailingCharacter = wdTrailingTab
  .NumberStyle = wdListNumberStyleBullet
  .NumberPosition = CentimetersToPoints(0.63) ' See the function described earlier!
  .Alignment = wdListLevelAlignLeft
  .TextPosition = CentimetersToPoints(1.27)
  .TabPosition = CentimetersToPoints(1.27)
  .ResetOnHigher = 0
  .StartAt = 1
  With .Font
   .Bold = wdUndefined
   .Italic = wdUndefined
   .StrikeThrough = wdUndefined
   .Subscript = wdUndefined
   .Superscript = wdUndefined
   .Shadow = wdUndefined
   .Outline = wdUndefined
   .Emboss = wdUndefined
   .Engrave = wdUndefined
   .AllCaps = wdUndefined
   .Hidden = wdUndefined
   .Underline = wdUndefined
   .Color = wdUndefined
   .Size = wdUndefined
   .Animation = wdUndefined
   .DoubleStrikeThrough = wdUndefined
   .Name = "Symbol"
  End With
  .LinkedStyle = ""
 End With

Next step is now to give a name to the gallery, but since we are not saving the gallery and will only use it this one time, we will set the name to an empty string:

objListGalleries(wdBulletGallery).ListTemplates(1).Name = ""

Now, we will apply the gallery as soon as we want to start to use the bullet list:

objWord.Selection.Range.ListFormat.ApplyListTemplate objListGalleries(wdBulletGallery).ListTemplates(1), False, wdListApplyToWholeList, wdWord9ListBehavior

Then type the text... In the example here we will have two bullets with the first entry stating ASDF and the second will be GHIJKLM.

objWord.Selection.TypeText "ASDF"
objWord.Selection.TypeParagraph
objWord.Selection.TypeText "GHIJKLM"
objWord.Selection.TypeParagraph

When the bullet list is complete, then turn off the listformat/gallery to resume normal text:

objWord.Selection.Range.ListFormat.RemoveNumbers wdNumberParagraph
objWord.Selection.TypeText "Another line"

Now, all we have to do is to save the document:

objDoc.SaveAs("C:\Temp\testdocument.docx")
objDoc.Close
objWord.Quit
' Garbage collection of variables:
Set objListGalleries = Nothing
Set objDoc = Nothing
Set objWord = Nothing

That's it! This is how to create a word document with bullet list - completely programmatically.


  • Actions Show Menu▼


expanded Attachments (0)
collapsed Attachments (0)
Edit the article to add or modify attachments.
expanded Versions (4)
collapsed Versions (4)
Version Comparison     
VersionDateChanged by              Summary of changes
This version (4)Jul 13, 2010, 11:06:44 AM~Richard Zekboosilyettu  
3Jul 6, 2010, 11:31:21 AM~Vanessa Preponelyynds  
2Jul 6, 2010, 11:29:37 AM~Vanessa Preponelyynds  
1Jul 6, 2010, 11:28:33 AM~Vanessa Preponelyynds  
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedAbout
  • HCL Software
  • HCL Digital Solutions community
  • HCL Software support
  • BlogsDigital Solutions blog
  • Community LinkHCL Software forums and blogs
  • About HCL
  • Privacy
  • Accessibility