我试图通过复制2个不同单元格中的值来插入带有图片和一些文本的标题。我尝试使用谷歌搜索功能,但以某种方式设法获得的图像仅在可打印模式下出现,而在工作簿中不出现。下面是我尝试过的代码。
Dim ws As Worksheet
Set ws = Worksheets("Output")
With ws.PageSetup
.CenterFooterPicture = "&G" 'Specifies that you want an image in your footer
.CenterFooterPicture.Filename = "C:\Users\Public\Pictures\Sample Pictures\Desert.jpg"
End With
正在生成新工作簿时,带有图片和文本的标题也应放在其中
答案 0 :(得分:1)
CenterFooterPicture
文档说明:
必须将“&G”作为
CenterFooter
属性字符串的一部分,以使图像显示在中心页脚中。
类似于文档提供的示例,请尝试:
Dim ws As Worksheet
Set ws = Worksheets("Output")
With ws.PageSetup
.CenterFooterPicture.Filename = "C:\Users\Public\Pictures\Sample Pictures\Desert.jpg"
End With
ws.PageSetup.CenterFooter = "&G" 'Specifies that you want an image in your footer
编辑:
根据您想要在左侧标题中显示图像的注释,尝试以下类似代码段:
Dim ws As Worksheet
Set ws = Worksheets("Output")
With ws.PageSetup
.LeftHeaderPicture.Filename = "C:\Users\Public\Pictures\Sample Pictures\Desert.jpg"
End With
ws.PageSetup.LeftHeader = "&G"