PDA

View Full Version : Load PNG File in Userform Image Control



Tony
02-14-2013, 03:10 AM
Gents,

I use a image control to load an exported image. When i use the gif or jpg i have no problems. But as soon i want to import the png file format it gives an error. When i use a Image1 and try loading a png through the image propertys it give the message invalid file.

I export the gif with a transparent background but the quality is realy poor thats why i want to use PNG:confused:



Private Sub UpdateChart()
Dim Fname As String
Dim i As Integer


Application.ScreenUpdating = False

For i = 1 To 3
Sheets("DASHBOARD").ChartObjects(i).Activate
ActiveChart.Parent.Width = 400
ActiveChart.Parent.Height = 180

' Save chart as GIF
Fname = ThisWorkbook.Path & Application.PathSeparator & i & "_temp.gif"
ActiveChart.Export FileName:=Fname, FilterName:="GIF"
Me.Controls("Image" & i).Picture = LoadPicture(Fname)

Application.ScreenUpdating = True
Next
End Sub

Excel Fox
02-14-2013, 12:06 PM
Did you try changing the file extension to .png and keep the filter as GIF


Fname = ThisWorkbook.Path & Application.PathSeparator & i & "_temp.png"

Admin
02-14-2013, 01:21 PM
Hi EF,

Does the PNG extension working for you ?

I do get error while uploadng PNG files. I'm using Excel 2010 on WIN 7.