I have some code that I need to repeat so I put it in a sub. But I think when it goes to the sub it is loosing the inheritance to the Word app class. The error is "invalid or unqualified reference".
Any idea how to keep the keep the class in the sub?
Thanks
Simi
Private Sub Command8_Click()
Dim wdApp As Word.Application
Set wdApp = New Word.Application
With wdApp
.Visible = True
.Activate
.Documents.Add
With .Selection
.Font.Name = "Calibri"
.Font.Size = 16
.BoldRun
.TypeText Me.jobtitle
.BoldRun
.TypeParagraph
End With
BulletedList ("This is one of my Items")
With Selection
.TypeText "Date Revised: " + Format(Now, "MMMM d, yyyy")
End With
End With
End Sub
Public Sub BulletedList(MyItem As String)
' ********************************************************
' * List with Blue Box
' ********************************************************
'Pre Spaces
With Selection
.Font.Color = RGB(91, 155, 213)
.TypeText " "
End With
'Box with Post Spaces
With Selection
.Font.Color = RGB(91, 155, 213)
.InsertSymbol Font:="Wingdings", CharacterNumber:=167, Unicode:=True
.TypeText " "
End With
'List text
With .Selection 'Error here
.Font.Color = wdBlack
.Font.Name = "Calibri"
.Font.Size = 11
.BoldRun
.TypeText MyItem
.BoldRun
.TypeParagraph
End With
' ********************************************************
End Sub
Any idea how to keep the keep the class in the sub?
Thanks
Simi
Private Sub Command8_Click()
Dim wdApp As Word.Application
Set wdApp = New Word.Application
With wdApp
.Visible = True
.Activate
.Documents.Add
With .Selection
.Font.Name = "Calibri"
.Font.Size = 16
.BoldRun
.TypeText Me.jobtitle
.BoldRun
.TypeParagraph
End With
BulletedList ("This is one of my Items")
With Selection
.TypeText "Date Revised: " + Format(Now, "MMMM d, yyyy")
End With
End With
End Sub
Public Sub BulletedList(MyItem As String)
' ********************************************************
' * List with Blue Box
' ********************************************************
'Pre Spaces
With Selection
.Font.Color = RGB(91, 155, 213)
.TypeText " "
End With
'Box with Post Spaces
With Selection
.Font.Color = RGB(91, 155, 213)
.InsertSymbol Font:="Wingdings", CharacterNumber:=167, Unicode:=True
.TypeText " "
End With
'List text
With .Selection 'Error here
.Font.Color = wdBlack
.Font.Name = "Calibri"
.Font.Size = 11
.BoldRun
.TypeText MyItem
.BoldRun
.TypeParagraph
End With
' ********************************************************
End Sub