The function below will add a table at the cursor location.

The table will not have any rows or columns. 

See to add rows and columns to the table.

Function TableHTMLAdd( _
ByVal strTitle As String) _
As Boolean
   On Error GoTo errHandler1
   TableHTMLAdd = False

   Dim strHTML As String
   Dim rng1 As webdesignerpage.TextRange
   Dim intTableIndexNumber As Integer

   strHTML = _
   vbCrLf & _
   vbTab & _
   "<table width=" _
   & """" & " 50%" & """" & _
   " cellspacing=" _
   & """" & "0" & """" & _
   " cellpadding=" & _
   """" & "3" & """" & _
   " title=" & _
   """" & strTitle & """" & ">" & _
   vbCrLf & _
   vbCrLf & _
   vbTab & _
   "</table>" & _
   vbCrLf

   'errHandler2 for next two lines
   'Try to fix automatically
   On Error GoTo errHandler2
   Set rng1 = WebDesigner.ActiveDocument. _
   Selection.createRange
   rng1.pasteHTML (strHTML)
   On Error GoTo errHandler1

   TableHTMLAdd = True

   Exit Function
errHandler1:
   MsgBox "TableHTMLAdd has failed", _
   vbCritical, "Function Failure"
   Exit Function
errHandler2:
   If Err.Number = 70 Then
   'Err.Number = 70 Is " Permission Denied"
   'Saving the ActivePageWindow
   'usually fixes this error.
   WebDesigner.ActivePageWindow.Save True

   'Automatically try again
   TableHTMLAdd (strTitle)
   TableHTMLAdd = True
Exit Function

Else
   MsgBox "TableHTMLAdd has failed", _
   vbCritical, "Function Failure"

End If

End Function				

The sub below can be used to call the TableHTMLAdd function.

blnSuccess will be true if the function succeeds and it will be false if the function fails.


Sub AddTableAttempt()
   Dim strTitle As String
   Dim blnSuccess As Boolean
   blnSuccess = TableHTMLAdd(strTitle)

   Exit Sub
errHandler1:
   'Notify user of failure.
   MsgBox "AddTableAttempt has failed", _
   vbCritical, "Function Failure"
End Sub
						

ActiveDocument HTML after the function succeeds.  The first line would noramlly not be wrapped on the ActiveDocument but I have space limitations on this page.

   <table width=" 50%" cellspacing="0" 
   cellpadding="3" title="">

   </table>

 

Valid XHTML 1.0 Transitional        Valid CSS!