(Hi everyone!) English is not my mother language, so forgive my writing errors and be my guest on a correction, will be apreciated. Let me introduce you in my issue. I'm having some troubles manipulating style list in word from vba in excel. I have a word template, an excel with data and this code (or at least part of it):
In the template the style list has a dot for level 1 no tabulation, circle for level 2 w/tabulation of 0.5cm, square for level 3 w/tabulation of 1cm, and so on.
After applied the ListIndent... first item sometimes keep his indent, but always has a dot. The others items are fine, a circle and tabulation. If I tried to indent twice, the first item keep the dot, but the indent is fine, but the others items has level 3, not 2, with square (not the circle was expected). And some times it make some abnormal format like put numbers to second and onward with no tabulation.
Can anyone tell me what i'm doing wrong?
Rich (BB code):
Rich (BB code):
Rich (BB code):
<code style="margin: **** padding: **** border: **** font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; white-space: inherit;">Function WriteParagraphWord(wdApp As Word.Application, ByVal myWorksheet As Worksheet, ByVal myParagraph As Integer) As Boolean
Dim mySelection As selection
Set mySelection = wdApp.selection
WriteParagraphWord = True
Dim colStyle As Integer
colStyle = FindColumn(myWorksheet, "Style")
mySelection.Paragraphs.Style = CStr(myWorksheet.Cells(myParagraph, colStyle).Value)
Dim colSpaceAfter As Integer
colSpaceAfter = FindColumn(myWorksheet, "SpaceAfter")
If myWorksheet.Cells(myParagraph, colSpaceAfter).Value <> "default" Then
mySelection.ParagraphFormat.SpaceAfter = myWorksheet.Cells(myParagraph, colSpaceAfter).Value
End If
Dim colBold As Integer
colBold = FindColumn(myWorksheet, "Bold")
If myWorksheet.Cells(myParagraph, colBold).Value = "All" Then
mySelection.Font.Bold = True
End If
Dim colList As Integer
colList = FindColumn(myWorksheet, "List")
Dim tipoList As String
typeList = myWorksheet.Cells(myParagraph, colList).Value
Select Case typeList
Case "dot"
Set listDot = wdApp.ActiveDocument.ListTemplates(7)
mySelection.Range.ListFormat.ApplyListTemplate ListTemplate:=listDot
Dim colNiveList As Integer
colLvlList = FindColumn(myWorksheet, "LvlList")
Dim lvlList As Integer
lvlList = CInt(myWorksheet.Cells(myParagraph, colLvlList).Value)
mySelection.Range.ListFormat.ListIndent '<=== PROBLEM IS HERE AND ONWARD (Other tries)
' If lvlList = 1 Then mySelection.Range.ListFormat.ListIndent
' If lvlList = 2 Then
' mySelection.Range.ListFormat.ListIndent
' mySelection.Range.ListFormat.ListIndent
' End If
' Dim nLvl As Integer
' For nLvl = 0 To lvlList
' mySelection.Range.ListFormat.ListIndent
' Next nLvl
End Select
Dim colTipo As Integer
colTipo = FindColumn(myWorksheet, "Tipo")
Select Case myWorksheet.Cells(myParagraph, colTipo).Value
Case "Image"
WriteParagraphWord = WriteImage(mySelection, myWorksheet, myParagraph)
Case "Text"
WriteParagraphWord = WriteText(mySelection, myWorksheet, myParagraph)
Case "Equation"
WriteParagraphWord = WriteEcuacion(mySelection, myWorksheet, myParagraph)
Case "Table"
WriteParagraphWord = WriteTable(mySelection, myWorksheet, myParagraph)
End Select
If myWorksheet.Cells(myParagraph, colBold).Value = "All" Then
mySelection.Font.Bold = False
End If
mySelection.TypeParagraph
'If typeList <> "default" Then mySelection.Range.ListFormat.ListOutdent
End Function</code>
After applied the ListIndent... first item sometimes keep his indent, but always has a dot. The others items are fine, a circle and tabulation. If I tried to indent twice, the first item keep the dot, but the indent is fine, but the others items has level 3, not 2, with square (not the circle was expected). And some times it make some abnormal format like put numbers to second and onward with no tabulation.
Can anyone tell me what i'm doing wrong?
Last edited by a moderator: