有什么代码可以解决 Presentation.GetThumbnails加载的图片不清晰
时间: 2024-02-19 22:03:32 浏览: 28
你提到的 `Presentation.GetThumbnails` 是 PowerPoint VBA 中的一个方法,用于获取演示文稿的缩略图。如果加载的图片不清晰,可能与图片的分辨率有关。你可以尝试修改图片的分辨率或者修改加载图片的代码,以便加载更高分辨率的图片。以下是一些可能有用的代码示例:
1. 修改图片分辨率
你可以使用 `Presentation.Export` 方法将演示文稿中的图片导出为高分辨率图片,然后使用导出的图片替换原始图片。以下是一个示例代码:
```
Sub ExportThumbnails()
Dim slide As Slide
Dim imagePath As String
Dim exportPath As String
For Each slide In ActivePresentation.Slides
With slide.Shapes(1)
imagePath = .MediaFormat.Parent.FullName
exportPath = "C:\Temp\" & .Name & ".jpg"
.Export exportPath, ppShapeFormatJPG, 3000, 2250
.Delete
slide.Shapes.AddPicture exportPath, msoFalse, msoTrue, .Left, .Top, .Width, .Height
End With
Next slide
End Sub
```
2. 加载高分辨率的图片
如果你不能通过修改图片分辨率来解决问题,你可以尝试直接加载高分辨率的图片。以下是一个示例代码:
```
Sub LoadHighResImage()
Dim slide As Slide
Dim imagePath As String
For Each slide In ActivePresentation.Slides
With slide.Shapes(1)
imagePath = .MediaFormat.Parent.FullName
.Delete
slide.Shapes.AddPicture imagePath, msoFalse, msoTrue, .Left, .Top, .Width, .Height
End With
Next slide
End Sub
```
这段代码会删除原始的图片,并使用 `AddPicture` 方法加载高分辨率的图片。
希望这些代码可以帮助你解决问题。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)