如何让我的代码将两个jpeg都接受为png文件

时间:2018-10-22 18:09:21

标签: excel vba png

我对客户徽标有以下代码,需要将其放置在文本框中。我已经发现.png文件无法正常工作。 不幸的是,我的数据库中有50%是.png文件,因此我希望这里的人可以为我提供使用.png文件的适当解决方法。

这是适用于.jpeg文件的代码

Sub ShapePicture()
    Dim xSh As Shape
    Dim xPic As IPictureDisp
    Dim xFileName As String

       With Application.FileDialog(msoFileDialogFilePicker)
        .AllowMultiSelect = False
        .ButtonName = "Submit"
        .Title = "Selecteer het logo van de klant"
        .Filters.Clear
        .Filters.Add "All Pictures", "*.*"

        If .Show = -1 Then
            For Each vrtSelectedItem In .SelectedItems
               Logopath = vrtSelectedItem
            Next vrtSelectedItem

        Else
            MsgBox ("Macro gestopt - Logo is vereist")
            Stop
        End If
    End With
    For Each Sh In Sheets
        If Sh.Name Like "Logo" Then
            Sheets("Logo").Delete
        End If
    Next

    Set xPic = LoadPicture(Logopath)
    Set xSh = Sheets("Voorblad").Shapes("LogoBox")
    xSh.Height = 55
    Set xPic = LoadPicture("")
    Set xPic = Nothing
    xSh.Fill.UserPicture Logopath

End Sub

0 个答案:

没有答案