Haloo ! I am writing in outlook 2007 macro what si working with xlsx. In some row ic code is error
Sub WriteToExcelFile()
Dim xlApp As Object
Dim xlWorkbook As Object
Dim xlWorksheet As Object
Dim filePath As String
On Error Resume Next 'firstly, try catching the existing open session, if any:
Set xlApp = GetObject(, "Excel.Application")
If Err.Number <> 0 Then 'if no any existing session, create a new one:
Err.Clear: Set xlApp = CreateObject("Excel.Application")
MsgBox "Object created"
End If
On Error GoTo 0
' Set the file path of the Excel file
filePath = "c:\moje_dokumenty\E-Recept\data.xlsx"
' Create a new instance of Excel
' Open the Excel file
'On row is mistake "call was reejected calee"
Set xlWorkbook = xlApp.Workbooks.Open(filePath)
'other code write with sheet in c:\moje_dokumenty\E-Recept\data.xlsx
' Check if the file exists
If Dir(filePath) <> "" Then
MsgBox "The file exists."
Else
MsgBox "The file does not exist."
End If
.
End sub
'Version Office 2007
'References in Outlook and Excel Visual basic Application:
'Microsoft Office Excel 12.Object Library
'Microsoft Excel 12.Object Library
How can I solve my problem ? Thanks for help !
Sub WriteToExcelFile()
Dim xlApp As Object
Dim xlWorkbook As Object
Dim xlWorksheet As Object
Dim filePath As String
On Error Resume Next 'firstly, try catching the existing open session, if any:
Set xlApp = GetObject(, "Excel.Application")
If Err.Number <> 0 Then 'if no any existing session, create a new one:
Err.Clear: Set xlApp = CreateObject("Excel.Application")
MsgBox "Object created"
End If
On Error GoTo 0
' Set the file path of the Excel file
filePath = "c:\moje_dokumenty\E-Recept\data.xlsx"
' Create a new instance of Excel
' Open the Excel file
'On row is mistake "call was reejected calee"
Set xlWorkbook = xlApp.Workbooks.Open(filePath)
'other code write with sheet in c:\moje_dokumenty\E-Recept\data.xlsx
' Check if the file exists
If Dir(filePath) <> "" Then
MsgBox "The file exists."
Else
MsgBox "The file does not exist."
End If
.
End sub
'Version Office 2007
'References in Outlook and Excel Visual basic Application:
'Microsoft Office Excel 12.Object Library
'Microsoft Excel 12.Object Library
How can I solve my problem ? Thanks for help !