我是vb.net的新手,我想打开一个现有的excel文件,并将图像插入特定的单元格,例如'C16',例如。
这是三天了,我正在搜索这个主题,但我发现只是创建一个新的excel文件并插入图片。
有人可以帮忙吗?
答案 0 :(得分:0)
可以使用的代码如下:
ActiveSheet.Pictures.Insert(pathForPicture & "\" & pictureName & ".jpg").Select 'Path to where pictures are stored
有关本网站的更多信息,请访问:VBA to insert embeded picture excel
How to insert a picture into Excel at a specified cell position with VBA
答案 1 :(得分:0)
我已经找到了解决方案: 请在下面找到
workbook = APP.Workbooks.Open(filepath)
worksheet = workbook.Worksheets("name of the excel sheet")
worksheet.Visible = True
Dim pic1 As String = "picture path"
worksheet.Range("I51:I51").Select()
I51是我想要我的照片的单元格
worksheet.PageSetup.Zoom = False
worksheet.PageSetup.FitToPagesWide = 1
worksheet.PageSetup.FitToPagesTall = 1
Dim opicture1 As Object
opicture1 = worksheet.Pictures.Insert(pic1)