2023-01-09 11:36:38
delphi 如何将word转换为pdf
使用vba来指定保存的文件格式为pdf,当然前提必须已安装ms office的pdf输出插件(默认应该有)
procedure tform1.btn1click(sender: tobject);
var
wdo,wdoc,wdocs : olevariant;
begin
wdo := createoleobject('word.application');
wdocs := wdo.documents;
wdoc := wdocs.open('d:\test.docx');
wdoc.exportasfixedformat(outputfilename:=
'd:\test.pdf', exportformat:=17);
//查word的宏帮助
{ openafterexport:='true', optimizefor:='wdexportoptimizeforprint', range:=
'wdexportalldocument', from:=1, to:=1, item:='wdexportdocumentcontent',
includedocprops:='true', keepirm:='true', createbookmarks:=
'wdexportcreatenobookmarks', docstructuretags:='true', bitmapmissingfonts:=
'true', useiso19005_1:='false'); }
end;
求高手execl word 的vba 转化为execl 中使用 - 百度...
sub macro1()
cells.select
selection.interior.colorindex = xlnone
sc = inputbox("请输入要查询的内容", "查找内容")
if sc <> "" then
cells.find(what:=sc, after:=activecell, lookin:=xlformulas, lookat:= _
xlpart, searchorder:=xlbyrows, searchdirection:=xlnext, matchcase:=false _
, matchbyte:=false, searchformat:=false).activate
activecell.select
with selection.interior
.color = vbgreen
.pattern = xlsolid
end with
end if
end sub
vba,将word的一段文字自动保存为rtf文件
sub 宏2()
'
' 宏2 宏
'
'
selection.copy
documents.add template:="normal", newtemplate:=false, documenttype:=0
selection.pasteandformat (wdpastedefault)
selection.wholestory
selection.copy
fname = mid(selection.text, 1, 5) & ".doc"
activedocument.saveas2 filename:=fname, fileformat:=wdformatrtf, _
lockcomments:=false, password:="", addtorecentfiles:=true, writepassword _
:="", readonlyrecommended:=false, embedtruetypefonts:=false, _
savenativepictureformat:=false, saveformsdata:=false, saveasaoceletter:= _
false, compatibilitymode:=0
activewindow.close
end sub
在执行宏之前要选中一段文字。默认的文件名是前5个字,保存的位置是我的文档,如果不行的话,可以搜索*.rtf。
在线交流。