Creating Bullets with VBA in Word from Access leads to odd behavior

I am creating a Monthly Report function that outputs to a Word document to a daily task Access database. However I’m seeing odd behavior when creating the bullet points.
*** I know that I can create reports but I don’t want to =) The formatting didn’t look the same***

Code explanation:
I have a button on a form that kicks off Sub btnCreateReport_Click()
Within that I created a Sub to clean up the paragraph / bullet creation called Sub fnNewPara
Additionally, I created another function that will eventually pull the text data from a database called Function fnGetActivities()

I use ParaIsSubBullet as a counter of how many indents I’m going to implement at a given line.

It’s easy to see how it’s skewed in the attached image.
Problem being is that if I just pass a blank string or blank space as text it formats perfectly.
If I add any text then it skews after the first iteration of the sub sub bullet.
side by side comparison of the text output

Here is the code:

Sub fnNewPara( _
n As Integer, _
ParaText As Variant, _
ParaFont As String, _
ParaFontSize As Integer, _
paraUnderline As Boolean, _
paraBold As Boolean, _
ParaIsBullet As Boolean, _
ParaIsSubBullet As Integer, _
ParaAlign As Integer, _
wdDoc As Object _
)

    wdDoc.Paragraphs.Add
    wdDoc.Paragraphs(n).Range.Text = ParaText & vbNewLine
    wdDoc.Paragraphs(n).Range.Font.Name = ParaFont
    wdDoc.Paragraphs(n).Range.Font.Size = ParaFontSize
    wdDoc.Paragraphs(n).Range.Font.Underline = paraUnderline
    wdDoc.Paragraphs(n).Range.Font.Bold = paraBold
    wdDoc.Paragraphs(n).Format.Alignment = ParaAlign
    
    If ParaIsBullet = True Then
    wdDoc.Paragraphs(n).Range.ListFormat.ApplyBulletDefault
    End If
    
    If ParaIsSubBullet > 0 Then
    Do Until ParaIsSubBullet = 0
    
    wdDoc.Paragraphs(n).Range.ListFormat.ListIndent
    
    ParaIsSubBullet = ParaIsSubBullet - 1
    Loop
    

    
    End If
    
    If ParaIsOutdent = True Then
    wdDoc.Paragraphs(n).Range.ListFormat.Listoutdent
    End If
    

End Sub

Function fnGetActivities() As String

fnGetActivities = "a" ' adding text to the sub sub bullet creates odd behavior not linked to this function

End Function



Private Sub btnCreateReport_Click()
 
    Dim wdApp As Object
    Dim wdDoc As Object
    Dim ParaFontSize As Integer
    Dim ParaAlign As Integer
    Dim ParaText As String
    Dim ParaFont As String
    Dim strFont As String
    Dim paraUnderline As Boolean
    Dim paraBold As Boolean
    Dim ParaIsBullet As Boolean
    Dim ParaIsSubBullet As Boolean
    Dim n As Integer
    Dim l As Integer
    Dim s As Integer
    Dim strLocation As Variant
    Dim strSection As Variant
    Dim strYear As String
    Dim strMonth As String
    
    strSection = Array("Section1", "Section2", "Section3")  ' arrays ind start at 0
    strLocation = Array("Location1", "Location2", "Location3")
    
    myFileName = "TestReport.docx"
    myFileDest = Application.CurrentProject.Path & "output" & myFileName

    strYear = "2024"
    strMonth = "June"
    strFont = "Times new roman"
    
    Set wdApp = CreateObject("Word.Application")
    wdApp.Visible = True ' Make Word application visible
    Set wdDoc = wdApp.Documents.Add
       
    '#########################################################
    
    n = 1
    s = 0
    l = 0

  ' fnNewPara (n, Text, Font, FontSize, Underline, Bold, IsBullet, IsSubBullet,IsOutdent,NumofBulletIndents, Align, ObjectDef)
  
    fnNewPara n, "Monthly Activity Report for " & strMonth & " " & strYear, "Times new roman", 12, True, True, False, 0, 1, wdDoc
    n = n + 1

Do Until s > 2
    fnNewPara n, strSection(s), "Times new roman", 12, True, True, True, 1, 0, wdDoc
    n = n + 1
    
    Do Until l > 2
       fnNewPara n, strLocation(l), strFont, 12, False, False, True, 2, 0, wdDoc
       n = n + 1
       fnNewPara n, fnGetActivities, strFont, 12, False, False, True, 3, 0, wdDoc
       n = n + 1
       l = l + 1
    Loop
 s = s + 1
 l = 0
 Loop

    
    '#########################################################
    
    ' Save the document
    'wdDoc.SaveAs myFileDest
    
    ' Optionally, close Word application
    'wdApp.Quit
    
    ' Release the objects
    Set subPara = Nothing
    Set para = Nothing
    Set wdDoc = Nothing
    Set wdApp = Nothing
    

New contributor

Charles is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật