设置环境:
我正在使用vb.net开发Excel 2010应用程序级加载项。
我的目标:
这段代码可以临时保存然后删除一个.png文件:
'Create temporary file path using the commonapplicationdata folder
Dim picturepath As StringBuilder
picturepath = New StringBuilder(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData))
picturepath.Append("\chartGridlines.png")
'Save resources into temp location in HD
My.Resources.grayGrid.Save(picturepath.ToString, System.Drawing.Imaging.ImageFormat.Png)
'Add picture to the worksheet
With Globals.ThisAddIn.Application.Selection.ShapeRange.Fill
.UserPicture(picturepath.ToString())
End With
'Clean up and delete the png from commonapplicationdata folder
System.IO.File.Delete(picturepath.ToString())
.xlsm文件怎么做?
有人会为我提供如何执行此操作的指示吗?我真的很感激。
就是这样:
Imports System.IO
...
File.WriteAllBytes("C:\Path\to\NameList.xlsm", My.Resources.NameList)
区别在于,图像存储为位图对象,而Excel文件存储为字节数组。
干杯
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句