Just do like this:
Imports System.IO
...
File.WriteAllBytes("C:\Path\to\NameList.xlsm", My.Resources.NameList)
The difference is because the image is stored as a Bitmap object, but the Excel file is stored as a byte array.
Cheers
Pregunta
Setup Environment:
I'm developing an Excel 2010 Application Level Add-in using vb.net.
My goal:
This code works to temporarily save and then delete a .png file:
'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())
How to do the same thing for .xlsm file?
Would someone provide a pointer on how I could go about doing this? I'd really appreciate it.
Solución
Just do like this:
Imports System.IO
...
File.WriteAllBytes("C:\Path\to\NameList.xlsm", My.Resources.NameList)
The difference is because the image is stored as a Bitmap object, but the Excel file is stored as a byte array.
Cheers