Export to Excel from datragid in Factorytalk view SE (local station)

ramses28

Member
Join Date
Mar 2024
Location
South America
Posts
2
Hi, I'm trying to export data from a DataGrid to Excel using VBA, but I'm getting an error "Object doesn't support this property or method". The code is the following:

Private Sub Button1_Released()
Dim ExcelApp As Object
Dim ExcelWorkbook As Object
Dim ExcelSheet As Object
Dim i As Integer
Dim j As Integer

' Crear una instancia de Excel
Set ExcelApp = CreateObject("Excel.Application")
ExcelApp.Visible = True ' Hacer visible Excel

' Crear un nuevo libro en Excel
Set ExcelWorkbook = ExcelApp.Workbooks.Add
Set ExcelSheet = ExcelWorkbook.Sheets(1)

' Copiar datos del DataGrid a Excel
For i = 0 To DataGrid1.RowCount - 1
For j = 0 To DataGrid1.ColumnCount - 1
ExcelSheet.Cells(i + 1, j + 1).Value = DataGrid1.Rows(i).Cells(j).Value
Next j
Next i


Dim sFileName As String
sFileName = Application.GetSaveAsFilename(FileFilter:="Excel Files (*.xls), *.xls", Title:="Guardar como")

If sFileName <> "False" Then
ExcelWorkbook.SaveAs sFileName
ExcelWorkbook.Close
ExcelApp.Quit
MsgBox "Exportación completada."
Else
ExcelWorkbook.Close False
ExcelApp.Quit
MsgBox "Exportación cancelada."
End If

' Limpiar variables
Set ExcelSheet = Nothing
Set ExcelWorkbook = Nothing
Set ExcelApp = Nothing
End Sub

According to what I have searched on Google, it is because the object does not have the property. So I wanted to know the correct way to export this data.
Thank you for your attention and help.
 

Similar Topics

Hey everybody, I have a bunch of bits used for diagnostics all compiled into a couple of DINTS. I have an x-ref sheet in Excel that aligns...
Replies
8
Views
1,869
I am using Siemens Step 7 v5.6 I am trying to Export all Tags along with the tag comments for a excel sheet. Does anyone have any idea how to...
Replies
13
Views
8,833
Hi all , I changed my TP1200 to PC runtime and added a trend screen so i can monitor the speed of the machine vs all time of the day I need to...
Replies
0
Views
1,056
Hi I have a recipe i want to convert to excel for documentation purposes. I know i can export to xml and open that in Excel Is there a method or...
Replies
0
Views
1,556
Hi A customer of mine is running Fix32 v7.0 and has asked if there is any way the historical data can be exported into excel. As it stands the...
Replies
4
Views
2,535
Back
Top Bottom