When I try to open a workbook in my Excel application I get the error 1004 ("the file .....xlsx can't be opened because the file extension or the file format isn't correct"). I have checked this and the extension as the format is correct. I got the error on the line ".[FONT="]Workbooks.Open (txtOpenWerkboekPad)"[/FONT]
Additionally I try to make a Excel macro in my Access application. Is that possible?
Code:
[FONT="] Dim XL As Object[/FONT]
[FONT="] Dim OpenWerkboek As Object[/FONT]
[FONT="] Set XL = CreateObject("Excel.Application")[/FONT]
[FONT="] txtOpenWerkboekPad = "C:\IGEANToets_FE\TeVersturenExcels\" & txtStamboeknummerVersturen & ".xlsx"[/FONT]
[FONT="] With XL[/FONT]
[FONT="] .Visible = False[/FONT]
[FONT="] .DisplayAlerts = False[/FONT]
[FONT="] .Workbooks.Open (txtOpenWerkboekPad)[/FONT]
[FONT="] With .OpenWerkboek[/FONT]
[FONT="] .Range("A2").Select[/FONT]
[FONT="] ' .Range("A2", Selection.End(xlDown)).Select[/FONT]
[FONT="] End With[/FONT]
[FONT="] OpenWerkboek.SaveAs "C:\IGEANToets_FE\TeVersturenExcels\" & txtStamboeknummerVersturen & ".xlsx"[/FONT]
[FONT="] End With[/FONT]
[FONT="] OpenWerkboek.Close[/FONT]
[FONT="] XL.Close[/FONT]
[FONT="] Set OpenWerkboek = Nothing[/FONT]
[FONT="] Set XL = Nothing[/FONT]