Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3
Default Worksheets.add in VBScript overwrites existing worksheet

Background: Opening a tab delimited file, generated by netsh, with Excel to
format the data. Formatting includes creating new worksheets.

Here's the short code in vbscript:
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''
Set objExcel = WScript.CreateObject("Excel.Application")
'Opening existing Workbook
Set objExcelWorkbook = objExcel.Workbooks.Open(filename)
'Adding worksheet to opened, existing workbook
objExcel.Worksheets.Add
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''

What happens with the above code is the data in the existing worksheet gets
overwritten, but the name of the worksheet is retained.

Value add:
Any good reference on vbscriipt, Excel specific objects & methods would be
appreciated. VBA references tend toward VB and not VBScript, which means you
waste a lot of time trying to figure out what objects and methods are
available and how they should be formatted.

Thanks in advance.

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3
Default Worksheets.add in VBScript overwrites existing worksheet

I've narrowed it down to the fact that the output file is not
xlWorkbookNormal format. I can't seem to change that when I do a SaveAs to a
new name. I get a message that the object doesn't support that method, i.e.,
FileFormat:=.

Any help still appreciated.

"donparkerjr" wrote:

Background: Opening a tab delimited file, generated by netsh, with Excel to
format the data. Formatting includes creating new worksheets.

Here's the short code in vbscript:
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''
Set objExcel = WScript.CreateObject("Excel.Application")
'Opening existing Workbook
Set objExcelWorkbook = objExcel.Workbooks.Open(filename)
'Adding worksheet to opened, existing workbook
objExcel.Worksheets.Add
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''

What happens with the above code is the data in the existing worksheet gets
overwritten, but the name of the worksheet is retained.

Value add:
Any good reference on vbscriipt, Excel specific objects & methods would be
appreciated. VBA references tend toward VB and not VBScript, which means you
waste a lot of time trying to figure out what objects and methods are
available and how they should be formatted.

Thanks in advance.

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 751
Default Worksheets.add in VBScript overwrites existing worksheet

How about

objExcelWorkbook.Worksheets.Add?

Does it demonstrate the same behavior?

HTH
Kostis Vezerides


donparkerjr wrote:
Background: Opening a tab delimited file, generated by netsh, with Excel to
format the data. Formatting includes creating new worksheets.

Here's the short code in vbscript:
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''
Set objExcel = WScript.CreateObject("Excel.Application")
'Opening existing Workbook
Set objExcelWorkbook = objExcel.Workbooks.Open(filename)
'Adding worksheet to opened, existing workbook
objExcel.Worksheets.Add
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''

What happens with the above code is the data in the existing worksheet gets
overwritten, but the name of the worksheet is retained.

Value add:
Any good reference on vbscriipt, Excel specific objects & methods would be
appreciated. VBA references tend toward VB and not VBScript, which means you
waste a lot of time trying to figure out what objects and methods are
available and how they should be formatted.

Thanks in advance.


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3
Default Worksheets.add in VBScript overwrites existing worksheet

It works... I know I tried that, too (I even have it commented out in my
code), but it didn't work before.

How frustrating.

Thank you for your solution.



"vezerid" wrote:

How about

objExcelWorkbook.Worksheets.Add?

Does it demonstrate the same behavior?

HTH
Kostis Vezerides


donparkerjr wrote:
Background: Opening a tab delimited file, generated by netsh, with Excel to
format the data. Formatting includes creating new worksheets.

Here's the short code in vbscript:
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''
Set objExcel = WScript.CreateObject("Excel.Application")
'Opening existing Workbook
Set objExcelWorkbook = objExcel.Workbooks.Open(filename)
'Adding worksheet to opened, existing workbook
objExcel.Worksheets.Add
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''

What happens with the above code is the data in the existing worksheet gets
overwritten, but the name of the worksheet is retained.

Value add:
Any good reference on vbscriipt, Excel specific objects & methods would be
appreciated. VBA references tend toward VB and not VBScript, which means you
waste a lot of time trying to figure out what objects and methods are
available and how they should be formatted.

Thanks in advance.



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


Similar Threads
Thread Thread Starter Forum Replies Last Post
If then formulas K Excel Worksheet Functions 12 August 30th 06 02:29 PM
How:Add New Worksheet that copies the cell of the previous sheet JLM Excel Worksheet Functions 1 August 24th 06 08:04 PM
is it possible to apply template to a existing worksheet Andy Excel Worksheet Functions 2 May 12th 06 09:31 PM
How do I convert an existing MS Excel worksheet tracking a simple. [email protected] Excel Discussion (Misc queries) 0 January 4th 05 12:53 AM
Creating new worksheet from existing ddpen Excel Discussion (Misc queries) 2 December 1st 04 10:35 PM


All times are GMT +1. The time now is 05:21 PM.

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"