If you want to know whether or not a particular Office component is available before attempting automation...
VB Code:
Private Enum OfficeComponents Word = 0 Excel = 1 PowerPoint = 2 Access = 3 End Enum Private Function IsOfficeComponentInstalled(Component As OfficeComponents) As Boolean Dim s As String Dim o As Object Select Case Component Case Word: s = "Word" Case Excel: s = "Excel" Case PowerPoint: s = "PowerPoint" Case Access: s = "Access" End Select On Error Resume Next Set o = CreateObject(s & ".Application") IsOfficeComponentInstalled = Not (o Is Nothing) Set o = Nothing End Function Private Sub Command1_Click() MsgBox IsOfficeComponentInstalled(Word) MsgBox IsOfficeComponentInstalled(Excel) MsgBox IsOfficeComponentInstalled(PowerPoint) MsgBox IsOfficeComponentInstalled(Access) End Sub




Reply With Quote