Set myxls = CreateObject("Excel.Application")
myxls.Visible = True
myxls.Workbooks.Open App.Path & "\Template.xls" myxls.ActiveSheet.Range(A3).Select '选定单元格
With myxls.ActiveSheet.Pictures.Insert(C:\Pic.jpg) '插入到选定的单元格中
.Width = 150
.Height = 200
End With测试环境:
XP + Office 2003
XP + Office 2007Office 2003中没有问题,Office 2007中,不能对应到指定单元格,会错位。
Office 模板是100%显示比例还有使用worksheet.shapes.addpicture方法只能指定坐标,我需要的是指定单元格。求助各位达人,在线等候
myxls.Visible = True
myxls.Workbooks.Open App.Path & "\Template.xls" myxls.ActiveSheet.Range(A3).Select '选定单元格
With myxls.ActiveSheet.Pictures.Insert(C:\Pic.jpg) '插入到选定的单元格中
.Width = 150
.Height = 200
End With测试环境:
XP + Office 2003
XP + Office 2007Office 2003中没有问题,Office 2007中,不能对应到指定单元格,会错位。
Office 模板是100%显示比例还有使用worksheet.shapes.addpicture方法只能指定坐标,我需要的是指定单元格。求助各位达人,在线等候
Office 2007位置就不对了。?
ActiveSheet.[C5].Activate
With ActiveSheet.Pictures.Insert("C:\Pic.jpg")
.Width = 150
.Height = 200
End With
End Sub
alzeng:谢谢你的测试,我去下载Office2010去测试下目前要解决的是Office2007,手动加入图片,图片贴在选定的单元格,而用代码加入图片,图片就贴在已选定的单元格,郁闷了一星期!!!
目前要解决的是Office2007,手动加入图片,图片贴在选定的单元格,而用代码加入图片,图片就不会贴在已选定的单元格,郁闷了一星期!!!