1.在word模板中设定 <#title> 区域,我想用指定数据替换掉它,word中宏代码如下,如何改造成vfp代码
Sub Macro3()
'
' Macro3 Macro
' 宏在 2007-5-20 由 Juice 录制
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = " <#TJBH> "
.Replacement.Text = " <#TJBHa> "
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAllwdReplaceAll
End Sub
2.如何新建word文件并另存为mht网页文件,我的代码如下,可是用浏览器打不开,我不知道如何转换一下
oword = CREATEOBJECT( "Word.application ")
_fileName = FULLPATH( "AttachFile\通知通告\ " + ALLTRIM(STR(Year(date()))) + IIF(month(date()) < 10 , "0 " + ALLTRIM(STR(month(date()))), ALLTRIM(STR(month(date())))) + IIF(Day(date()) < 10 , "0 " + ALLTRIM(STR(Day(date()))), ALLTRIM(STR(Day(date())))) + ".mht ")
oword.Documents.Add
oword.ActiveDocument.Saveas(_fileName)
oword.Visible = .T.
首先感谢大家!
------解决方案--------------------------------------------------------
第1个问题:可以参考
VFP统计WORD文件中某一词或字出现的次数
*-------------------------------------
例如,Word文件名为XWY.DOC,内容为:
中华人民共和国
中国
人民大会堂
以下为统计“人民”、“国”和“华”这几个词或字的出现次数:
WAIT "正在访问 Word 软件…… " WINDOW NOWAIT
WOLE=CREATEOBJECT( "Word.application ")
IF TYPE( "WOLE ")# "O "
WAIT CLEAR
MESSAGEBOX( "访问Word失败!请检查你的系统是否正确安装 Word 软件! ",48, "没有安装Word ")