Im trying to edit a Cell in my Excel Sheet with an ActiveX Macro (from Powerpoint). But the value never appears in that cell. I even see in the file explorer that the File have been edited.
Private Sub ScrollBar1_Change()
Dim xlApp As Object
Dim xlSheet As Object
Dim scrollbarValue As Integer
' Verweis auf Excel herstellen
On Error Resume Next
Set xlApp = GetObject(, "Excel.Application")
On Error GoTo 0
If xlApp Is Nothing Then
Set xlApp = CreateObject("Excel.Application")
End If
' Fehlerbehandlung für den Dateizugriff
On Error GoTo ErrorHandler
' Arbeitsmappe öffnen
xlApp.Workbooks.Open "{absolute path}\Diagramm.xlsx"
' Blatt auswählen (hier das erste Blatt)
Set xlSheet = xlApp.Worksheets(1)
' Wert der Scrollleiste abrufen
scrollbarValue = ScrollBar1.Value
' Wert in Excel-Zelle eintragen
xlSheet.Cells(1, "A").Value = scrollbarValue
' Excel schließen
xlApp.Quit
' Speicher freigeben
Set xlSheet = Nothing
Set xlApp = Nothing
Exit Sub
ErrorHandler:
MsgBox "Fehler beim Zugriff auf die Excel-Datei: " & Err.Description
' Freigabe von Ressourcen
If Not xlSheet Is Nothing Then Set xlSheet = Nothing
If Not xlApp Is Nothing Then
xlApp.Quit
Set xlApp = Nothing
End If
End Sub
I've tried writing hard-coded Values , with xlSheet.Range("A1").Value = and other formats .Cells(1, 1) but nothing appears
Write to Excel From PowerPoint