主题:急需,那位大侠帮忙!!!小弟感激不尽
jieju
[专家分:0] 发布于 2008-03-11 09:54:00
在我运行这个程序的时候,第一次是能够写入模版中去的,在不关闭form1的情况下继续运行为什么不能写入东西了呢??我刚接触不是很懂,那位大侠帮帮忙,急用!!
(template.dot是个两行五列的表格)
Private Sub Command1_Click()
CreatRpt
End Sub
Public Function CreatRpt(Optional vCondition As Integer = 0)
Dim MyDocExcecution As New Word.Application '设置word对象
On Error Resume Next
'执行打开新的模板
Set MyDocExcecution = New Document
' Set MyDocExcecution = Documents.Open(FileName:=App.Path + "\template" + "\template.dot")
' Set MyDocExcecution = GetObject(, "Word.Application")
MyDocExcecution.Documents.Open FileName:=App.Path + "\template" + "\template.dot"
MyDocExcecution.Visible = True '显示新建文档
' MyDocExcecution.Documents(0).Activate '激活文档
'向表中填入内容
ActiveDocument.Tables(1).Cell(1, 1).Range.Text = "序号"
ActiveDocument.Tables(1).Cell(1, 2).Range.Text = "姓名"
ActiveDocument.Tables(1).Cell(1, 3).Range.Text = "出生年月"
ActiveDocument.Tables(1).Cell(1, 4).Range.Text = "籍贯"
ActiveDocument.Tables(1).Cell(1, 5).Range.Text = "工作单位"
MyDocExcecution.ScreenUpdating = True
MyDocExcecution.ActiveDocument.SaveAs FileName:=App.Path + "\template" + "通知", fileformat:=doc, Password:=""
Word.Application.Quit
End Function
最后更新于:2008-03-11 23:02:00
回复列表 (共10个回复)
沙发
jieju [专家分:0] 发布于 2008-03-11 10:04:00
在不关闭form1的情况下继续运行为什么不能写入东西了呢??继续运行=继续点击command1
板凳
FieldMAX [专家分:12740] 发布于 2008-03-11 12:10:00
程序发过来,我给你看看
3 楼
asanscape [专家分:1350] 发布于 2008-03-11 18:24:00
COM.麻烦....闪人...
4 楼
jieju [专家分:0] 发布于 2008-03-11 23:03:00
我把程序传上去了,先谢谢大侠了。
5 楼
FieldMAX [专家分:12740] 发布于 2008-03-12 08:30:00
Private Sub Command1_Click()
CreatRpt
End Sub
Public Function CreatRpt(Optional vCondition As Integer = 0)
Dim MyDocExcecution As New Word.Application '设置Excel对象
On Error Resume Next
'执行打开新的模板
Set MyDocExcecution = New Document
' Set MyDocExcecution = Documents.Open(FileName:=App.Path + "\template" + "\template.dot")
' Set MyDocExcecution = GetObject(, "Word.Application")
MyDocExcecution.Documents.Open FileName:=App.Path + "\template" + "\template.dot"
MyDocExcecution.Visible = True '显示新建文档
' MyDocExcecution.Documents(0).Activate '激活文档
'向表中填入内容
MyDocExcecution.ActiveDocument.Tables(1).Cell(1, 1).Range.Text = "序号"
MyDocExcecution.ActiveDocument.Tables(1).Cell(1, 2).Range.Text = "姓名"
MyDocExcecution.ActiveDocument.Tables(1).Cell(1, 3).Range.Text = "出生年月"
MyDocExcecution.ActiveDocument.Tables(1).Cell(1, 4).Range.Text = "籍贯"
MyDocExcecution.ActiveDocument.Tables(1).Cell(1, 5).Range.Text = "工作单位"
MyDocExcecution.ScreenUpdating = True
MyDocExcecution.ActiveDocument.SaveAs FileName:=App.Path + "\template" + "通知", fileformat:=doc, Password:=""
MyDocExcecution.Quit
'Word.Application.Quit
End Function
6 楼
jieju [专家分:0] 发布于 2008-03-12 20:11:00
我就想问一句,你的那么多分是怎么来的啊,你到底行不行啊,不行别逗人玩好不好啊
7 楼
FieldMAX [专家分:12740] 发布于 2008-03-12 21:29:00
[quote]
我就想问一句,你的那么多分是怎么来的啊,你到底行不行啊,不行别逗人玩好不好啊[/quote]
。。。
8 楼
joforn [专家分:1460] 发布于 2008-03-12 22:25:00
Public Function CreatRpt(Optional vCondition As Integer = 0)
Dim MyDocExcecution As Word.Application '设置Excel对象
On Error GoTo 0
'执行打开新的模板
Set MyDocExcecution = New Word.Application
MyDocExcecution.Documents.Open FileName:=App.Path & "\template" & "\template.dot"
MyDocExcecution.Visible = True '显示新建文档
'向表中填入内容
Debug.Print MyDocExcecution.ActiveDocument.Name
MyDocExcecution.ActiveDocument.Tables(1).Cell(1, 1).Range.Text = "序号"
MyDocExcecution.ActiveDocument.Tables(1).Cell(1, 2).Range.Text = "姓名"
MyDocExcecution.ActiveDocument.Tables(1).Cell(1, 3).Range.Text = "出生年月"
MyDocExcecution.ActiveDocument.Tables(1).Cell(1, 4).Range.Text = "籍贯"
MyDocExcecution.ActiveDocument.Tables(1).Cell(1, 5).Range.Text = "工作单位"
MyDocExcecution.ScreenUpdating = True
MyDocExcecution.DisplayAlerts = False
MyDocExcecution.ActiveDocument.SaveAs FileName:=App.Path & "\template" & "通知", fileformat:=doc, Password:=""
DoEvents
MyDocExcecution.ActiveDocument.Close
MyDocExcecution.Quit
Set MyDocExcecution = Nothing
End Function
9 楼
jieju [专家分:0] 发布于 2008-03-13 14:58:00
谢谢啊
10 楼
老大徒伤悲 [专家分:29120] 发布于 2008-03-18 13:26:00
[quote]作者:jieju
专家分:0
会员信息
发短消息
所属BLOG 发表时间:2008-3-12 20:11:00 [回复] [引用]
6 楼
我就想问一句,你的那么多分是怎么来的啊,你到底行不行啊,不行别逗人玩好不好啊 [/quote]我实在不知道该说什么了!
[quote]主题:急需,那位大侠帮忙!!!小弟感激不尽[/quote]难道感谢就是这样子的?
我来回复