Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
mohit
 
Posts: n/a
Default Not able to set Name of the workbook

Hello,

Not able to set Name of the workbook


My Javascript code look like this
JSActiveXObj = new ActiveXObject("Excel.Application");
JSNewWorkbook = JSActiveXObj.Workbooks.Add();

This code is working fine.

but if i try to give a name to the workbook using this code
JSActiveXObj = new ActiveXObject("Excel.Application");
JSNewWorkbook = JSActiveXObj.Workbooks.Add("xyx");

Sometimes it works fine but most of the times it is giving error. :(

Any help will be highly appreciated.
--
thanks and regards,
mohit
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

You can't name a workbook in this way, Excel assigns the name in a list
Book1, Book2, etc. You only assign the name when you save it.

But it shouldn't matter, the variable JSNewWorkbook points at the workbook.

--
HTH

Bob Phillips

"mohit" wrote in message
...
Hello,

Not able to set Name of the workbook


My Javascript code look like this
JSActiveXObj = new ActiveXObject("Excel.Application");
JSNewWorkbook = JSActiveXObj.Workbooks.Add();

This code is working fine.

but if i try to give a name to the workbook using this code
JSActiveXObj = new ActiveXObject("Excel.Application");
JSNewWorkbook = JSActiveXObj.Workbooks.Add("xyx");

Sometimes it works fine but most of the times it is giving error. :(

Any help will be highly appreciated.
--
thanks and regards,
mohit



  #3   Report Post  
mohit
 
Posts: n/a
Default

Thanks Bob for the message...

But in my scenario I am exporting some data from the application to the
Excel sheet on a button click.As i want to ask user to save the file anywhere
by opening file open dialog box. I dont want to hardcode the path.
For this reason, I am not saving the file in my code. I am just closing the
file and excel is automatically asking user about saving of the file.
JSNewWorkbook.Close(1); // i m passing one so that it will not show the
message asking if you want to save the changes or not

But the problem is that i want to show the name of the file based on some
numbers. Suppose we are exporting the details of the employee. I want to give
the file name based on employee number.
Is there any workaround?

--
thanks and regards,
mohit


"Bob Phillips" wrote:

You can't name a workbook in this way, Excel assigns the name in a list
Book1, Book2, etc. You only assign the name when you save it.

But it shouldn't matter, the variable JSNewWorkbook points at the workbook.

--
HTH

Bob Phillips

"mohit" wrote in message
...
Hello,

Not able to set Name of the workbook


My Javascript code look like this
JSActiveXObj = new ActiveXObject("Excel.Application");
JSNewWorkbook = JSActiveXObj.Workbooks.Add();

This code is working fine.

but if i try to give a name to the workbook using this code
JSActiveXObj = new ActiveXObject("Excel.Application");
JSNewWorkbook = JSActiveXObj.Workbooks.Add("xyx");

Sometimes it works fine but most of the times it is giving error. :(

Any help will be highly appreciated.
--
thanks and regards,
mohit




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
HOW DO I SUM TWO CELLS FROM ONE WORKBOOK TO ANOTHER WORKBOOK? Bill O'Neal Excel Worksheet Functions 8 August 14th 09 11:36 PM
Linking a cell to another workbook cell based on a variable name Brian Excel Discussion (Misc queries) 6 June 1st 05 11:54 PM
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM
Unprotect Workbook Kent Excel Discussion (Misc queries) 1 February 4th 05 01:07 AM
Stubborn toolbars in Excel 007 Excel Discussion (Misc queries) 9 December 11th 04 02:02 PM


All times are GMT +1. The time now is 08:08 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"