AngeliqueAPF
New member
- Local time
- Today, 19:11
- Joined
- Dec 20, 2017
- Messages
- 3
Hi,
I inserted a button in one Access-form, that is bound to a VBA-module intended to transfer the values of the form's controls to an already existing Excel-worksheet. My problem is, that I simply cannot seem to open this Excel-file, even if this should be a rather simple task.
Below, I inserted the relevant (!) parts of the code.
The error message tells me, the file couldn't be found, even though, the Dir-Function can perfectly find it, which is why the error message can return the name of the file.
I tried some alternations and the following was already checked:
-Excel-library is referenced in Access
-if I skip the asterisk around the filename it doesn't work either
-if I choose "AppExcel = CreateObject(„ExcelApplication“)" over "New Excel.Application", the error message just tells me, the object wouldn't support the method
-the workbook was also saved in a different path, which didn't work either
Do you know something I could try?
Thanks for your replies!
I inserted a button in one Access-form, that is bound to a VBA-module intended to transfer the values of the form's controls to an already existing Excel-worksheet. My problem is, that I simply cannot seem to open this Excel-file, even if this should be a rather simple task.
Below, I inserted the relevant (!) parts of the code.
Code:
Private Sub Command_Click()
Dim AppExcel As New Excel.Application
Dim strName As String
Dim strPath As String Dim wbook As Excel.Workbook
strPath = "Y:\...\...\"
strName = Dir("Y:\...\...\*filename*.xlsx")
On Error Resume Next
Set wbook = AppExcel.Workbooks(strName)
On Error GoTo Fehler
If wbook Is Nothing Then
Set wbook = AppExcel.Workbooks.Open(strPath & strName)
End If
wbook.Visible = True
(…….)
Exit Sub
Fehler: MsgBox Err.Description
End Sub
The error message tells me, the file couldn't be found, even though, the Dir-Function can perfectly find it, which is why the error message can return the name of the file.
I tried some alternations and the following was already checked:
-Excel-library is referenced in Access
-if I skip the asterisk around the filename it doesn't work either
-if I choose "AppExcel = CreateObject(„ExcelApplication“)" over "New Excel.Application", the error message just tells me, the object wouldn't support the method
-the workbook was also saved in a different path, which didn't work either
Do you know something I could try?
Thanks for your replies!