Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default using SaveAs to save 'only' one sheet from one book to a new file

Hi,

I'm trying to save just ONLY one sheet from a work book to with many sheet's to a new htm(l) file.

But with the following code, it saves all the sheets and just defaults to the one sheet when the htm file is opened, but all sheets are there and visible and can be selected.

Any help would be appreciated.

Thanks in andvance,
-Randy W


$excel = new COM("Excel.Application") or die('...');
$excel - Workbooks - Open($file);

$book = $excel - Workbooks(1);
$sheet = $book - Worksheets(1);

$newfilename = getcwd()."\graph.htm";
$sheet - SaveAs($newfilename,44); // <- trying to save just one sheet as htm file.
$book - Close(true);

unset($sheet);
unset($book);

$excel - Workbooks - Close();
$excel - Quit();
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default using SaveAs to save 'only' one sheet from one book to a new file

Randy W,

I'm not familiar with your programming language, but I've been able to
reproduce your problem within VBA.

Worksheet.Copy will create a copy of that worksheet in a new workbook. So,
the trick to to save the temporary workbook as html then close it.

Sub testit()
ThisWorkbook.Worksheets(1).Copy
Application.ActiveWorkbook.SaveAs "c:\t\test2.htm", 44
Application.ActiveWorkbook.Close SaveChanges:=False
End Sub

Rob


"Randy W" wrote in message
...
Hi,

I'm trying to save just ONLY one sheet from a work book to with many

sheet's to a new htm(l) file.

But with the following code, it saves all the sheets and just defaults to

the one sheet when the htm file is opened, but all sheets are there and
visible and can be selected.

Any help would be appreciated.

Thanks in andvance,
-Randy W


$excel = new COM("Excel.Application") or die('...');
$excel - Workbooks - Open($file);

$book = $excel - Workbooks(1);
$sheet = $book - Worksheets(1);

$newfilename = getcwd()."\graph.htm";
$sheet - SaveAs($newfilename,44); // <- trying to save just one sheet as

htm file.
$book - Close(true);

unset($sheet);
unset($book);

$excel - Workbooks - Close();
$excel - Quit();



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default using SaveAs to save 'only' one sheet from one book to a new file

Hey, thanks for the response

I'm using COM through PHP. I've been attempting what you recommeneded, but something's not right in my code. I get what you're saying though and see how it should work

Thanks again
-Randy
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 email one sheet from within an excell work book file Marguerite Excel Worksheet Functions 1 April 29th 08 05:06 PM
copy the same raws of all sheets from about a 100 file to a new sheet of a book and save the file [email protected] Setting up and Configuration of Excel 0 March 14th 07 02:13 AM
Save and Saveas Greyed out on tool bar and file menu Shareena Howley Setting up and Configuration of Excel 1 July 5th 05 01:02 PM
Is there away to keep "auto save" from jumping to the first work sheet in the work book? Marc New Users to Excel 2 April 21st 05 01:27 AM
copy printarea from more than 3 sheet & save in new book. Shital Excel Programming 1 October 4th 03 10:47 AM


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