如何将*.DOC转为*.HTML格式(内容如题)?(200分)

  • 主题发起人 主题发起人 exceed
  • 开始时间 开始时间
E

exceed

Unregistered / Unconfirmed
GUEST, unregistred user!
如何将*.DOC转为*.HTML格式(内容如题)?
 
The first and easiest is to save the document as HTML. If Doc is a
connected TWordDocument:
FileName := 'D:/Docs/Word/TestHTML.htm';
Fmt := wdFormatHTML;
Doc.SaveAs(FileName, Fmt);
You can then use the saved file and delete it when you've finished.

If you really don't want to do that, though, you could use the
clipboard instead - just copy the whole document and then use
Clipboard.GetAsHandle(CF_HTML) to get at the data. Using the
clipboard like that is a bit antisocial, however, so I'll move on to
method three, which is similar but uses the Word document's
IDataObject interface:

var
CF_HTML: Word;

var
Doc: WordDocument;
DataObj: IDataObject;
FormatEtc: TFormatEtc;
SM: TstgMedium;
TextPtr: PChar;
..
Doc := WordApp.ActiveDocument;
DataObj := Doc as IDataObject;
Assert(DataObj <> nil);

FormatEtc.cfFormat := CF_HTML;
FormatEtc.tymed := TYMED_HGLOBAL;
FormatEtc.ptd := nil;
FormatEtc.dwAspect := DVASPECT_CONTENT;
FormatEtc.lindex := -1;

OleCheck(DataObj.GetData(FormatEtc, SM));
TextPtr := GlobalLock(SM.hGlobal);
Memo1.Lines.Text := StrPas(TextPtr);
GlobalUnlock(SM.hGlobal);
ReleaseStgMedium(SM);

initialization
CF_HTML := RegisterClipboardFormat('HTML Format');

---------------------------------------------
以前在国外网站上看到的
 
接受答案了.
 
后退
顶部