ComponentOne VSView 8.0
Step 5: Exporting to HTML

Exporting the calendar to HTML is also very easy, because the VSPrinter control has built-in HTML export capability through the ExportFile and ExportFormat properties.

To launch the browser and allow the user to see the calendar, we need to declare the ShellExecute Windows API. Here is the declare statement needed:

Example Title
Copy Code
Option Explicit

 

' use the current browser to show HTML file

Private Declare Function ShellExecute _

   Lib "shell32.dll" Alias "ShellExecuteA" ( _

   ByVal hwnd As Long, ByVal lpOperation As String, _

   ByVal lpFile As String, _

   ByVal lpParameters As String, _

   ByVal lpDirectory As String, _

   ByVal nShowCmd As Long) As Long

 

' base date used to build the calendar

Dim TheDate As Date

Once the ShellExecute function has been declared, exporting the calendar to HTML and showing it to the user is pretty simple. Double-click the View HTML button and add the following code to the cmdHTML_Click event handler:

Example Title
Copy Code
Private Sub cmdHTML_Click()

 

  ' set name of HTML output file

  vp.ExportFile = App.Path & "\cal.htm"

  vp.ExportFormat = vpxDHTML

 

  ' refresh calendar

  ShowCalendar

 

  ' show file in browser

  ShellExecute hwnd, "open", vp.ExportFile, 0, 0, 0

 

  ' clear HTML output file

  vp.ExportFile = ""

 

End Sub

The code starts by setting the ExportFile and ExportFormat properties, which define the type of export file you want and its name and location on disk. Then, the calendar is regenerated, creating the HTML file.

Finally, the ShellExecute function is called to display the HTML file, and the ExportFile property is cleared to avoid accidentally overwriting the HTML file.

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback