Doctype is the declaration above the html start tag.

It is also called Document Type Definition and DTD.

The following code will extract it from the ActiveDocument.

strDocType = Mid(ActiveDocument.documentHTML, _
1, InStr(1, _
ActiveDocument.documentHTML, "<html") - 1)

ActiveDocument.documentHTML includes everything in the document.

The mid method strips off everything after the "<html" tag.

The InStr method finds the position of the "<html" tag.

Sample Output

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 
Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">	

 

Valid XHTML 1.0 Transitional        Valid CSS!