// InvokeCmd
procedure InvokeCMD(InvokeIE: Boolean; Value1, Value2: Integer; var vaIn, vaOut: OleVariant);
var
CmdTarget: IOleCommandTarget;
PtrGUID, PtrGUID2: PGUID;
begin
New(PtrGUID);
try
if InvokeIE then
begin
PtrGUID2 := PtrGUID;
PtrGUID2^ := CLSID_WebBrowser;
end
else
PtrGuid2 := nil;
if DefaultInterface.Document <> nil then
try
DefaultInterface.Document.QueryInterface(IOleCommandTarget, CmdTarget);
if CmdTarget <> nil then
try
CmdTarget.Exec(PtrGuid2, Value1, Value2, vaIn, vaOut);
finally
CmdTarget := nil; //._Release;
end;
except
end;
finally
Dispose(PtrGUID);
end;
end;
procedure PrintPreview;
var
vaIn, vaOut: Olevariant;
begin
InvokeCmd(FALSE, OLECMDID_PRINTPREVIEW, OLECMDEXECOPT_DODEFAULT, vaIn, vaOut);
end;