乔山办公网我们一直在努力
您的位置:乔山办公网 > word文档 > 如何用vfp实现对word的控制-vfp控制word,vfp控制word替换文字

如何用vfp实现对word的控制-vfp控制word,vfp控制word替换文字

作者:乔山办公网日期:

返回目录:word文档


VFP下直接调用EXCEL、WORD文件的方法:可先建个按钮或菜单——执行如下代码:
DECLARE INTEGER ShellExecute IN shell32.DLL INTEGER HWND,STRING, ;
STRING lpszFile, STRING, STRING, INTEGER
operate= "open"
ShellExecute(0,operate,"C:\111.XLS",0,0,1) && EXCEL文件
ShellExecute(0,operate,"C:\111.DOC",0,0,1) && WORD文件

用VFP命令控制Word1、创建Word文档Appword=CreateObject("word.application")2、显示Word文档Appword.Visible=.t.3、建立新文档Appword.Documents.Add()4、保存文档Appword.ActiveDocument.SaveAs("E:\abc.doc")5、打开文档Appword.ActiveDocument.Open("E:\abc.doc")6、保存Appword.ActiveDocument.Save7、关闭Appword.ActiveDocument.Close8、退出Appword.Application.Quit9、打印Appword.ActiveDocument.PrintOut10、设置上页边距Appword.ActiveDocument.PageSetup.TopMargin=1.5/0.03511、设置下页边距Appword.ActiveDocument.PageSetup.BottomMargin=1.5/0.03512、设置左页边距Appword.ActiveDocument.PageSetup.LeftMargin=1.5/0.03513、设置右页边距Appword.ActiveDocument.PageSetup.RightMargin=1.5/0.03514、设置页宽e799bee5baa6e79fa5e98193e4b893e5b19e361Appword.ActiveDocument.PageSetup.PageWidth=18.4/0.03515、设置页高Appword.ActiveDocument.PageSetup.PageHeight=26/0.03516、设置页面竖放Appword.ActiveDocument.PageSetup.Orientation=117、设置页面横放Appword.ActiveDocument.PageSetup.Orientation=218 、指定网格Appword.ActiveDocument.PageSetup.LayoutMode=0    && 0--不指定网格  1--指定网格和字符网格 2--指定行网格 3--文字对齐网格19、设置每页行数Appword.ActiveDocument.PageSetup.LinesPage=4220、设置每行字数Appword.ActiveDocument.PageSetup.ChartLine=1021、页面设为4栏Appword.ActiveDocument.PageSetup.TextColumns.SetCount(4)22、设置栏宽Appword.ActiveDocument.PageSetup.TextColumns.Width=3/0.03523、设置栏间距Appword.ActiveDocument.PageSetup.TextColumns.Specing=0.5/0.03524、插入文字Appword.Selection.Text="如果创建了工具栏"25、插入文字Appword.Selection.InsertAfter(space(6)+"多谢贵公司的支持!")26、指定字号Appword.Selection.FontSize=10.527、设置对齐方式Appword.Selection.ParagraphFormat.Alignment=0 && 0为左对齐 1居中 2右对齐 3两端对齐28、设置字体Appword.Selection.FontName="宋体"29、删除光标前面的字符(回车符等)Appword.Selection.Typebackspace30、删除字符Appword.Selection.Delete(1,1) && 第一个数字:1为下删一字,2为下删到下一个标点  第二个数字为数量
你直接这样即zhidao可实现,保证好用
run start winword

或者
!start winword

run start excel
或者
!start excel

如果不用start ,那你则需要用set path to 指令路径

DECLARE INTEGER ShellExecute IN shell32.DLL INTEGER HWND,;
STRING lpszOP, ;
STRING lpszFile, ;
STRING lpszParams, ;
STRING lpszDir, ;
INTEGER fsshowcmd
DECLARE INTEGER GetDesktopWindow IN win32api
HWND = GetDesktopWindow()
lpszOP = "open"
* 指定要开的文件名
lpszFile =alltrim(filedir)+"help.doc"
lpszParams = ""
lpszDir = filedir
fsshowcmd =1
* 执行ShellExecute命令
LNRETURN = ShellExecute(HWND, lpszOP,lpszFile, lpszParams, lpszDir,fsshowcmd)

相关阅读

关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网