dim path as string Private Declare Function shellexecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpdirectory As String, ByVal nShowCmd As Long) As Long '鏈接 Private Const sw_shownormal = 1 Private Const sw_showminimized = 2 path="d:\123.doc" '文檔路徑 Call shellexecute(Me.hwnd, "open", path, vbNullString, vbNullString, sw_shownormal)
打开应该容易 Dim Wdapp As Word.Application Dim WdDocument As Word.Document Dim UserFile As String Set Wdapp = New Word.Application '先做一个word模板,然后打开 UserFile = App.Path & "\电子病历模板.doc" Set WdDocument = Wdapp.Documents.Open("F:\课题-论文\专家系统\电子病历模板.doc")
'填写内容 If Wdapp.ActiveDocument.Books.Exists("我") = True Then Wdapp.ActiveDocument.Books("我").Range.InsertAfter (Trim(comboSytd.Text)) End If
不过我有个问题,我想复制一个已经存在的word文档应该怎么做啊
declare function CopyFile lib "kernel32" alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) as long 这个API用来复制文件的 第一个参数是原文件的路径 第一个参数是复制文件路径 最后一个是当文件存在时候是否覆盖~0为覆盖~1为复制错误
Private Declare Function shellexecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpdirectory As String, ByVal nShowCmd As Long) As Long '鏈接
Private Const sw_shownormal = 1
Private Const sw_showminimized = 2
path="d:\123.doc" '文檔路徑
Call shellexecute(Me.hwnd, "open", path, vbNullString, vbNullString, sw_shownormal)
Dim Wdapp As Word.Application
Dim WdDocument As Word.Document
Dim UserFile As String
Set Wdapp = New Word.Application
'先做一个word模板,然后打开
UserFile = App.Path & "\电子病历模板.doc"
Set WdDocument = Wdapp.Documents.Open("F:\课题-论文\专家系统\电子病历模板.doc")
'填写内容
If Wdapp.ActiveDocument.Books.Exists("我") = True Then
Wdapp.ActiveDocument.Books("我").Range.InsertAfter (Trim(comboSytd.Text))
End If
这个API用来复制文件的
第一个参数是原文件的路径
第一个参数是复制文件路径
最后一个是当文件存在时候是否覆盖~0为覆盖~1为复制错误