Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 4th, 2005, 12:03 PM
Authorized User
 
Join Date: Oct 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default Copy a Worksheet as HTML

I wish to save a worksheet as an HTM file for email purposes.
Is this possible in VBA code?


 
Old April 5th, 2005, 12:31 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Sure. There is no built-in functionality for that, but there’s no difficulty in writhing a routine that selectively reads data from the worksheet, then writing it to a file, adding the necessary HTML elements to format the info.

Also, Excel does have the ability to save a worksheet as HTML . . . (Contained in the Save dialog.)
 
Old April 14th, 2005, 10:58 AM
Authorized User
 
Join Date: Oct 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the reply. Is it not possible to automate the same function as the excel save dialogue box within VBA code?

I really did not want to mess about with HTML syntax.



 
Old April 14th, 2005, 11:53 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Virtually anything you can do with the menu system can also be done with VBA.

I think you will have to create a User Form and put a common dialogs control on it.

In setting up the displaying of the Save / SaveAs dialog, add *.htm to the filter list.

Once the user has made their choices, use VBA to save the worksheet accordingly.

For me, recording a macro yielded the following:
Code:
    ActiveWorkbook.SaveAs Filename:="C:\Test.htm", FileFormat:=xlHtml, _
        ReadOnlyRecommended:=False, CreateBackup:=False
        Actually, in looking, I don’t see the CommonDialogs control. I’m sure that there is a standard way in Excel to show the various dialogs. I am just not sure what that is.

But once you have the filename to save to and the location, you can use the .SaveAs method of the workbook to do the actual work.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy worksheet to another workbook and rename it Probleminfinity Excel VBA 1 August 19th, 2007 11:38 PM
Data rewriting/copy between worksheet zone Excel VBA 0 August 9th, 2007 11:40 PM
Copy Worksheet into another workbook money Excel VBA 4 March 8th, 2007 05:17 AM
Copy a worksheet range to a new workbook cej2583 Excel VBA 2 March 14th, 2006 11:55 PM
Preserve Hyperlinks when Sending HTML Worksheet Ahrenl Excel VBA 4 February 8th, 2005 02:52 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.