Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default SheetsInNewWorkbook

Hello,

Does someone know why this doesn't work in VBA (Excel 97):

lTemp = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = 1
Set wbTarget = Workbooks.Add
Application.SheetsInNewWorkbook = lTemp

Gr. ROn...

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default SheetsInNewWorkbook

Hi

I can't test it for you but try this instead for a one sheet workbook

Workbooks.Add (1)
Or
Workbooks.Add (xlWBATWorksheet)



--
Regards Ron de Bruin
http://www.rondebruin.nl


"ROn..." wrote in message oups.com...
Hello,

Does someone know why this doesn't work in VBA (Excel 97):

lTemp = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = 1
Set wbTarget = Workbooks.Add
Application.SheetsInNewWorkbook = lTemp

Gr. ROn...



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default SheetsInNewWorkbook

"ROn..." wrote in message
oups.com...
Does someone know why this doesn't work in VBA (Excel 97):

lTemp = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = 1
Set wbTarget = Workbooks.Add
Application.SheetsInNewWorkbook = lTemp


Hi Ron,

This works OK for me in all current versions of Excel. Can you give a
bit more detail about what doesn't work when you try it. By the way, this
line of code will do exactly the same as the above for the special case
where you want a new workbook with a single worksheet:

Set wbTarget = Workbooks.Add(xlWorksheet)

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default SheetsInNewWorkbook

Hi Rob,

The error message translated from dutch error msg:

Error 1004

Method 'Sheetsinnewworkbook' from object '_Application' failed

Your option

Set wbTarget = Workbooks.Add(xlWorksheet)

works. Tnx!

Gr. ROn...

BTW: How can i create a workbook with 2 sheets?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default SheetsInNewWorkbook

Hoi Ron,

You're option also works.

Bedankt,

Gr ROn... ;-)



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default SheetsInNewWorkbook

Hi/Hoi Ron

BTW: How can i create a workbook with 2 sheets?

You must use SheetsInNewWorkbook

I go install a Dutch 97 version now to test it for you

I be back



--
Regards Ron de Bruin
http://www.rondebruin.nl


"ROn..." wrote in message ups.com...
Hi Rob,

The error message translated from dutch error msg:

Error 1004

Method 'Sheetsinnewworkbook' from object '_Application' failed

Your option

Set wbTarget = Workbooks.Add(xlWorksheet)

works. Tnx!

Gr. ROn...

BTW: How can i create a workbook with 2 sheets?



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default SheetsInNewWorkbook

Hi

I try it on a Virtual PC with The Dutch version of Excel 97 and it
is working correct there.

Is there other code in the sub ?


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Ron de Bruin" wrote in message ...
Hi/Hoi Ron

BTW: How can i create a workbook with 2 sheets?

You must use SheetsInNewWorkbook

I go install a Dutch 97 version now to test it for you

I be back



--
Regards Ron de Bruin
http://www.rondebruin.nl


"ROn..." wrote in message ups.com...
Hi Rob,

The error message translated from dutch error msg:

Error 1004

Method 'Sheetsinnewworkbook' from object '_Application' failed

Your option

Set wbTarget = Workbooks.Add(xlWorksheet)

works. Tnx!

Gr. ROn...

BTW: How can i create a workbook with 2 sheets?





  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default SheetsInNewWorkbook

ROn... wrote:
Does someone know why this doesn't work in VBA (Excel 97):

lTemp = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = 1
Set wbTarget = Workbooks.Add
Application.SheetsInNewWorkbook = lTemp


if you have an activeX control, it's probably this problem:

XL97: Error Changing Application Object from ActiveX Control
http://support.microsoft.com/default...b;en-us;177527

try to set TakeFocusOnClick property to false or "ActiveCell.Activate".

--
HTH,

okaizawa
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default SheetsInNewWorkbook

Hello okaizawa,

This seems to be working, tnx!

Gr. ROn...

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default SheetsInNewWorkbook

Yes this is a old 97 bug


--
Regards Ron de Bruin
http://www.rondebruin.nl


"ROn..." wrote in message ups.com...
Hello okaizawa,

This seems to be working, tnx!

Gr. ROn...



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"