Access交流中心

北京 | 上海 | 天津 | 重庆 | 广州 | 深圳 | 珠海 | 汕头 | 佛山 | 中山 | 东莞 | 南京 | 苏州 | 无锡 | 常州 | 南通 | 扬州 | 徐州 | 杭州 | 温州 | 宁波 | 台州 | 福州 | 厦门 | 泉州 | 龙岩 | 合肥 | 芜湖 | 成都 | 遂宁 | 长沙 | 株洲 | 湘潭 | 武汉 | 南昌 | 济南 | 青岛 | 烟台 | 潍坊 | 淄博 | 济宁 | 太原 | 郑州 | 石家庄 | 保定 | 唐山 | 西安 | 大连 | 沈阳 | 长春 | 昆明 | 兰州 | 哈尔滨 | 佳木斯 | 南宁 | 桂林 | 海口 | 贵阳 | 西宁 | 乌鲁木齐 | 包头 |

关于在word的表格中插入图片

三狼  发表于:2014-01-14 21:10:48  
复制

单击窗体上的Command1 , 打开在D:/123.doc ,在文档的表格的第2行,第2列中插入D:/456.jpg 的图片。

原想录制宏,但word录制宏,不支持鼠标操作,百度了几天了,头发都白了几根

只知道用InlineShapes.AddPicture FileName:D:/456.jpg

现跪求全码

 

Top
三狼 发表于:2014-01-15 00:11:18

没人的?把我的代码写一下,请老师修改,关闭程序后,第一次运行正常,第二次运行时出错,提示:远程服务器不存在或不可用。

Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

   Dim WordObj As Word.Application
   Dim WordDoc As Word.Document
   Dim Tabdoc As Word.Tables
       Set WordObj = CreateObject("Word.Application")
             WordObj.Visible = True
       Set WordDoc = WordObj.Documents.Open("D:\123.doc")
 ActiveDocument.Tables(1).Cell(2, 1).Range.Select
  Selection.InlineShapes.AddPicture FileName:= _
   D:\Backup\My Pictures\1\IMG_1308.jpg"
          WordDoc.SaveAs "d:\1.doc"
         WordObj.Quit SaveChanges:=wdDoNotSaveChanges
    Set WordDoc = Nothing
    Set WordObj = Nothing
Exit_Command0_Click:
    Exit Sub

Err_Command0_Click:
    MsgBox Err.Description
    Resume Exit_Command0_Click
  
End Sub




煮江品茶 发表于:2014-01-15 08:58:54
word文件可能处于打开状态

cspa 发表于:2014-01-15 09:27:41

哦,我遇到过这样的错误,这样改:(注意红色部分

Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

   Dim WordObj As Word.Application
   Dim WordDoc As Word.Document
   Dim Tabdoc As Word.Tables
       Set WordObj = CreateObject("Word.Application")
             WordObj.Visible = True
       Set WordDoc = WordObj.Documents.Open("D:\123.doc")
 WordDoc.ActiveDocument.Tables(1).Cell(2, 1).Range.Select
  WordDoc.Selection.InlineShapes.AddPicture FileName:= _
   D:\Backup\My Pictures\1\IMG_1308.jpg"
          WordDoc.SaveAs "d:\1.doc"
         WordObj.Quit SaveChanges:=wdDoNotSaveChanges
    Set WordDoc = Nothing
    Set WordObj = Nothing
Exit_Command0_Click:
    Exit Sub

Err_Command0_Click:
    MsgBox Err.Description
    Resume Exit_Command0_Click
  
End Sub



三狼 发表于:2014-01-15 15:18:41
不行啊,提示WordDoc没有selection方法啊

cspa 发表于:2014-01-15 16:09:14
WordDoc.ActiveDocument.Tables(1).Cell(2, 1).Range.Select
  WordDoc.Selection.InlineShapes.AddPicture FileName:= _
   D:\Backup\My Pictures\1\IMG_1308.jpg"
改为:

 WordObj.ActiveDocument.Tables(1).Cell(2, 1).Range.Select
  WordObj.Selection.InlineShapes.AddPicture FileName:= _
   "D:\Backup\My Pictures\1\IMG_1308.jpg"

另外你在D:\Backup\My Pictures\1\IMG_1308.jpg"  一句前少了一个 ",我给你加上了。



三狼 发表于:2014-01-15 16:26:36

,谢谢老师



总记录:6篇  页次:1/1 9 1 :