Since you're using automation, you might have to fully qualify the
application object reference.
objXL.objWB.Sheets(1).Name = strReportName
Otherwise I'd go with what Tom said, if you set a reference to the
Excel object library, you should declare the application object as
Excel.Application, not Object.
--JP
On Oct 15, 8:55*am, Ryan <R...@discussions.microsoft.com> wrote:
> The following protion of code worked perfect with Access 2003 and after I
> updated 2003 to 2007. Now we have new computers with a fresh install of
> Office 2007 and now I get Run-time error '-2147417851 (80010105)': Method
> 'Add' of object 'Workbooks' failed when the compiler hits the last line.
>
> ---------------------------------------------------------------------------*---------------
> * * Dim objXL As Object
> * * Dim objWB As Object
> * * Dim strReportName As String
>
> * * strReportTitle = "Report Name"
>
> * * 'Create a new excel document
> * * Set objXL = CreateObject("Excel.Application")
>
> * * 'To create new workbook
> * * Set objWB = objXL.Workbooks.Add 'This now creates the error. With or
> without parenthesis () at the end.
> * * objWB.Sheets(1).Name = strReportName
> ---------------------------------------------------------------------------*---------------------
>
|