ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Automation (https://www.excelbanter.com/excel-programming/422038-automation.html)

Kieran H

Automation
 
I am opening an instance of Excel 2007 from Access 2007

Set xlAPP = CreateObject("Excel.Application")
Set xlBook = xlAPP.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)

Unfortunately the Set xlBook = xlAPP.Workbooks.Add causes our
document management software to ewrror.

My guess is that the "Add" method somehow by passes the DM code that
would have been run had the workbook been opened.

I cannot trap the error - [object referenced without first being set]
as its not ocurring in my code

Can I use an "Open" method instead of "Add" to open a default new
workbook without the workbook existing or would I have to create the
workbook first.

As a workaround I have created an empty .xlt and use the open method
- this is not ideal as it creates a dependency on the empty file

Any thoght appreciated

Cheers

Kieran


JLGWhiz

Automation
 
Instead of:

Set xlBook = xlAPP.Workbooks.Add

Try:

xlAPP.Workbooks.Add



"Kieran H" wrote:

I am opening an instance of Excel 2007 from Access 2007

Set xlAPP = CreateObject("Excel.Application")
Set xlBook = xlAPP.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)

Unfortunately the Set xlBook = xlAPP.Workbooks.Add causes our
document management software to ewrror.

My guess is that the "Add" method somehow by passes the DM code that
would have been run had the workbook been opened.

I cannot trap the error - [object referenced without first being set]
as its not ocurring in my code

Can I use an "Open" method instead of "Add" to open a default new
workbook without the workbook existing or would I have to create the
workbook first.

As a workaround I have created an empty .xlt and use the open method
- this is not ideal as it creates a dependency on the empty file

Any thoght appreciated

Cheers

Kieran




All times are GMT +1. The time now is 01:37 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com