ich habe an folgendem Thread gesehen, dass man Excel mit COMatePlus steurn kann. Ich möchte etwas ähnliches machen wie in diesem Thread.
Es öffnet sich eine Excelliste, die schon mit einigen Daten befüllt ist. Das funktioniert soweit. Wenn die Liste bearbeitet wurde soll sie mit einem Klick auf speichern gespeichert werden können. Der User soll sich aber nicht damit beschäftigen wo die Datei hingespeichert werden soll; er soll einfach nur auf speichern klicken und die Datei soll dann an einem bestimmten Pfad abgespeichert werden. Es muss also im voraus schonmal eine Art "speichern unter" aufgerufen werden. Es sollte mit Excel 2003 und 2007 funktionieren.
Soweit bin ich gekommen aber leider funktioniert das nicht wirklich:
Code: Alles auswählen
XIncludeFile "COMatePLUS.pbi"
date$ = FormatDate("%dd/%mm/%yyyy", Date())
Define.COMateObject ExcelObject, WorkBook
ExcelObject = COMate_CreateObject("Excel.Application")
If ExcelObject
If ExcelObject\SetProperty("Visible = #True") = #S_OK
ExcelObject\Invoke("Workbooks\open('C:\users\xxx\desktop\test.xlsx')")
WorkBook = ExcelObject\GetObjectProperty("Workbooks\Add")
If WorkBook
ExcelObject\SetProperty("Cells(1,1) = 'Datum:'")
ExcelObject\SetProperty("Cells(1,2) = '" + date$ + "' AS DATE")
ExcelObject\SetProperty("Cells(3,1) = 'Lied:'")
ExcelObject\SetProperty("Cells(3,3) = 'COMate!'")
ExcelObject\SetProperty("Cells(3,4) = 'Today$0027s date is'") ;$0027 is a hex escape code used to insert a ' (ascii 39) character.
ExcelObject\SetProperty("Application\DisplayAlerts = #False")
ExcelObject\Invoke("Save")
ExcelObject\SetProperty("Application\DisplayAlerts = #True")
ExcelObject\Invoke("Quit()")
;ExcelObject\Invoke("Quit()")
WorkBook\Release()
EndIf
EndIf
ExcelObject\Release()
Else
MessageRequester("Excel Datei erstellen", "Couldn't create the application object!")
EndIf