如何在vfp中读取word中文字格式

lybaiyang 2012-07-31 05:58:00
我想利用VFP打开一个WORD文档,然后从文档中读出第二段中"中国"两个字的字体格式,请问怎么写代码呀?先谢谢大家!
...全文
308 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
arong_119 2012-08-02
  • 打赏
  • 举报
回复
将VFP的DBF导出到WORD


以下这段代码就能直接把一个DBF转为DOC
什么参数都不用加,在要在当前工作区打开表就行了

************************************
If Empty(Alias())
Messagebox( "当前工作区没有打开工作表!",48,"不能生成表格")
Endif
Wait "正在访问 Word 软件……" Window Nowait
WordApp=Createobject("Word.application") &&访问WORD
If Type("WordApp")#"O"
Wait Clear
Messagebox( "访问Word失败!请检查你的系统是否正确安装 Word 软件!",48,"没有安装Word")
Return
Endif
Wait "正在生成表格……" Window Nowait
WordApp.Visible =.F.
WordApp.Caption ='yafox.com'
WordApp.Documents.Add
WordApp.Documents(1).Range.Text=Alias()
WordApp.Documents(1).Range.Font.Size=15
WordApp.Documents(1).Range.Font.Name="黑体"
WordApp.Documents(1).Range.Paragraphs.Alignment= 1
WordAppRang=WordApp.Documents(1).Range(Lenc(WordApp.Documents(1).Range.Text)-1,Lenc(WordApp.Documents(1).Range.Text)-1)
WordTable=WordApp.Documents(1).Tables.Add(WordAppRang,Reccount()+1,Fcount())
WordTable.Range.Paragraphs.Alignment= 0
WordTable.Range.Font.Name="宋体"
WordTable.Range.Font.Size=11
WordTable.BorderS.Enable=1
WordTable.BorderS(1).LineWidth = 12
WordTable.BorderS(2).LineWidth = 12
WordTable.BorderS(3).LineWidth = 12
WordTable.BorderS(4).LineWidth = 12
WordTable.Rows(1).BorderS(3).LineWidth = 12
WordTable.Rows(1).Range.Font.Bold=.T.
WordTable.Rows(1).Cells.VerticalAlignment= 1
WordTable.Rows(1).Range.Paragraphs.Alignment = 1
WordTable.Rows(1).HeadingFormat=.T.

For i=1 To Fcount()
WordTable.Cell(1,i).Range.Text=Field(i)
For i2=2 To Reccount()+1
Go i2-1
WordCellText=Evaluate(Field(i))
Do Case
Case Isnull(WordCellText)
WordCellText=""
Case Type("WordCellText")="N"
Case Type("WordCellText")="D"
WordCellText=Dtoc(WordCellText)
Case Type("WordCellText")="T"
WordCellText=Ttoc(WordCellText)
Case Empty(WordCellText)
WordCellText=""
Otherwise
* WordCellText=""
Endcase
WordTable.Cell(i2,i).Range.Text=WordCellText
Next
WordTable.Columns(i).AutoFit
Next
WordApp.Documents(1).SaveAs("C:\Xwy.doc")
WordApp.Quit
Release WordApp
Wait Clear
Messagebox( "生成WORD文件完毕,文件位置 C:\Xwy.doc !",64,"完毕")
Return
/*--------------------
word = CreateObject( "word.application")
word.Visible = .T.
word.Documents.Add
word.ActiveWindow.ActivePane.View.SeekView = 9
word.Selection.Text="zhe li shi ye mei"
word.Selection.MoveDown(,1,)
word.Selection.Text="zhe li shi ye jiao"
*--------------
word = CreateObject( "word.application")
word.Visible = .T.
word.Documents.Open('c:\test.doc')
word.ActiveWindow.ActivePane.View.SeekView = 9
word.Selection.Text="zhe li shi ye mei"
word.Selection.MoveDown(,1,)
word.Selection.Text="zhe li shi ye jiao"

word.Selection.Sections(1).Headers(1).PageNumbers.Add(1) &&加页码
word.Selection.Sections(1).Footers(1).PageNumbers.Add(2)


2,722

社区成员

发帖
与我相关
我的任务
社区描述
VFP,是Microsoft公司推出的数据库开发软件,用它来开发数据库,既简单又方便。
社区管理员
  • VFP社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧