如何将多个PNG文件转换为JPEG格式

我一直在尝试转换一些文件,我在一个文件夹中的.png到.jpg使用vba,但我不能以一个代码来做到这一点,我一直在尝试将图像粘贴到Excel中并导出他们为JPG,但它似乎并没有工作,有人可以帮我这个吗? 我有代码,我试图这样做,我得到这一行的错误

ThisWorkbook.ActiveSheet.ChartObjects("foto").Chart.Export Filename:=x, FilterName:="JPEG" 

因为“这个成员只能接受一个图表对象”有人可以帮我吗?

 On Error Resume Next DisplayAlerts = True Application.ScreenUpdating = True Dim Pathh As String Dim fila As Integer Set fso = CreateObject("Scripting.FileSystemObject") Pathh = "C:\Users\jojeda\Desktop\Pruebas JPEG\" Set carpeta = fso.getfolder(Pathh) Set ficheros = carpeta.Files For Each ficheros In ficheros 'I belive the code should be here b = "C:\Users\jojeda\Desktop\Pruebas JPEG\" & ficheros.Name With ThisWorkbook.ActiveSheet.Pictures.Insert(b) .Placement = 1 .Name = "foto" .PrintObject = True End With ThisWorkbook.Worksheets("Sheet1").Cells(1, 6) = b ThisWorkbook.Worksheets("Sheet1").Range("F1").Replace ".png", ".jpg", xlPart b = ThisWorkbook.Worksheets("Sheet1").Cells(1, 6) x = Right(b, 8) ThisWorkbook.ActiveSheet.ChartObjects("foto").Chart.Export Filename:=x, FilterName:="JPEG" ThisWorkbook.Sheets("Sheet1").Shapes("foto").Delete Next ficheros DisplayAlerts = True Application.ScreenUpdating = True 

我想出了一个解决scheme,我自己的问题,我结束了加载图片的图片,然后导出文件作为JPEG文件,在另一个文件夹,万一有人正在寻找这样的事情,这是代码:

 Sub Button1_Click() DisplayAlerts = True Application.ScreenUpdating = True Dim Pathh As String Dim fila As Integer Set fso = CreateObject("Scripting.FileSystemObject") Pathh = "C:\Users\jojeda\Desktop\Pruebas JPEG\" Set carpeta = fso.getfolder(Pathh) Set ficheros = carpeta.Files For Each ficheros In ficheros b = "C:\Users\jojeda\Desktop\Pruebas JPEG\" & ficheros.Name c = "C:\Users\jojeda\Desktop\Pruebas JPEG2\" & ficheros.Name Set blab = ThisWorkbook.ActiveSheet.ChartObjects.Add(Left:=200, Width:=200, Top:=80, Height:=200) blab.Name = "foto" blab.Activate ActiveChart.ChartArea.Format.Fill.UserPicture (b) ThisWorkbook.Worksheets("Sheet1").Cells(1, 6) = b ThisWorkbook.Worksheets("Sheet1").Range("F1").Replace ".png", ".jpeg", xlPart b = ThisWorkbook.Worksheets("Sheet1").Cells(1, 6) ThisWorkbook.Worksheets("Sheet1").ChartObjects("foto").Chart.Export Filename:=c, FilterName:="JPEG" ThisWorkbook.Sheets("Sheet1").Shapes("foto").Delete Next ficheros DisplayAlerts = True Application.ScreenUpdating = True End Sub