I am working on an Access VBA project, and one step involves creating an Excel workbook.
I pulled a function from a book as a starting point, but when I try to execute it I get an error that says, "An error occurred trying to add new workbook: Object variable or With block variable not set". I think this might have something to do with my references (i.e. Tools > References), but I'm not sure what I'm doing wrong. I'll attach a screenshot of my selections. Also, I'm using Excel and Access 2013.
.
And here is the VBA function I'm referring to.
Code:
Function modExcel_CreateNewWorkBook() As Boolean
' Open an existing word document
On Error Resume Next
Set wkbExcel = appExcel.Workbooks.Add
If Err <> 0 Then
MsgBox "An error occured trying to add new workbook : " & Err.Description, vbCritical, "Unable To Create Workbook"
modExcel_CreateNewWorkBook = False
Else
modExcel_CreateNewWorkBook = True
End If
End Function