| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 509 人关注过本帖
标题:求助-VB6控制Word中插入的电子表格
只看楼主 加入收藏
huwenyi7758
Rank: 2
等 级:论坛游民
帖 子:24
专家分:11
注 册:2015-7-23
结帖率:100%
收藏
 问题点数:0 回复次数:2 
求助-VB6控制Word中插入的电子表格
Dim WordApp As Object, worddoc As Object
Private Sub Command5_Click()
   Dim L1 As Double, L2 As Double, L3 As Double
   Dim wrdDoc  'Modify
   Dim wrdPic  'Modify
   L1 = Text11.Text
   L2 = Text12.Text
   L3 = Text13.Text
   Label54.Caption = L1 + L2 + L3
   Label55.Caption = L1 * L2 * L3
   Label58.Caption = Text9.Text
   Label59.Caption = Text10.Text
   Dim wordObj
   Set wordObj = CreateObject("Word.Application")
   Set wrdDoc = wordObj.Documents.Open("E:\编程\##\##.docx") 'Modify
   With wrdDoc 'Modify
   'With wordObj.Documents.Open("E:\编程\##\##.docx")
     CommonDialog1.Filter = "Word文档(*.docx)|*.docx" '存储文件
     CommonDialog1.ShowSave
     If CommonDialog1.FileName = "" Then
       K1 = 3
     Else
       With .Content
         .Find.MatchCase = True
         .Find.Execute "{cd1}", , , , , , , , , Text11, 2
         .Find.Execute "{cd2}", , , , , , , , , Text12, 2
         .Find.Execute "{cd3}", , , , , , , , , Text13, 2
         .Find.Execute "{cd4}", , , , , , , , , Label54, 2
         .Find.Execute "{cd5}", , , , , , , , , Label55, 2
         .Find.Execute "{cd6}", , , , , , , , , Label58, 2
         .Find.Execute "{cd7}", , , , , , , , , Label59, 2
       End With
 Set wrdPic = wrdDoc.Shapes.AddPicture(FileName:="C:\Users\Administrator\Desktop\捕获.GIF", LinkToFile:=False, SaveWithDocument:=True, Left:=wrdShapeCenter, Top:=100)     'Modify
   
       .SaveAs CommonDialog1.FileName
     End If
   End With
   wordObj.Quit
 End Sub
该程序可以把我E:\编程\##\##.docx里面的{cd1}-{cd7}替换成了我算好的数据并选择另存为新的word文件,且插入图片。 但是我现在要在E:\编程\##\##.docx里面插入了一个电子表格,注意是2007版word里面插入“电子”表格,然后我想在表格里面先输入{cd1}-{cd7},想和我前面程序那样一样的替换出来我想要的数据然后保存一个新word不知道可否。。如若没有办法这样替换,可否有什么办法程序插入表格,并同理要在表格内输入text12.text-label59.caption已经算好的数值。在我原程序里面该加些什么,求大神帮忙谢谢!
搜索更多相关主题的帖子: Object Word 电子 
2015-08-08 14:22
huwenyi7758
Rank: 2
等 级:论坛游民
帖 子:24
专家分:11
注 册:2015-7-23
收藏
得分:0 
竟然没人。。
2015-08-10 08:07
china_shy_wz
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2020-6-5
收藏
得分:0 
学习学习
2020-06-05 16:57
快速回复:求助-VB6控制Word中插入的电子表格
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014641 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved