admin管理员组文章数量:1122832
First of all: I'm unfortunately not very familiar with PowerPoint or VBA. I tried to solve it with ChatGPT, but I can't get it to work. I have a presentation with 10 different slides. The presentation runs 24/7 and always starts over. On slides 4, 8, 12 and 16 I want to display an image that is on a server that is accessible on the Internet. It is a .jpg and I can access it directly via the URL (example: .jpg)
Important: The image always has the same name, but the content of the image can change. So when the above slides are displayed, I want the image to always be freshly loaded from the server and nothing to be fetched from the cache or anything like that. The size of the image in the slide should be adjustable in the code.
Can someone help me with this? Or does anyone have a sample PowerPoint that already contains a working macro or something that I just need to adapt? I've spent the whole day with ChatGPT and Google and nothing worked. I'm starting to despair. 2024 and PowerPoint can't display an image from a specific URL out of the box and without the help of scripts and add-ons...
I tried using ChatGPT, but the VBA code suggested to me didn't work. No image was inserted, the slide remained blank.
This is the code from ChatGPT:
Private Sub App_SlideShowNextSlide(ByVal Wn As SlideShowWindow)
Dim sld As slide
Dim shp As shape
Dim imgURL As String
' URL des Bildes
imgURL = ".png"
' Auf die aktuelle Folie zugreifen
Set sld = Wn.View.Slide
' Bild mit dem Namen "LiveBild" löschen und neu hinzufügen
For Each shp In sld.Shapes
If shp.Name = "LiveBild" Then
shp.Delete
End If
Next shp
sld.Shapes.AddPicture imgURL, msoFalse, msoCTrue, 100, 100, -1, -1 ' Position und Größe anpassen
End Sub
First of all: I'm unfortunately not very familiar with PowerPoint or VBA. I tried to solve it with ChatGPT, but I can't get it to work. I have a presentation with 10 different slides. The presentation runs 24/7 and always starts over. On slides 4, 8, 12 and 16 I want to display an image that is on a server that is accessible on the Internet. It is a .jpg and I can access it directly via the URL (example: https://myserver.com/myimage.jpg)
Important: The image always has the same name, but the content of the image can change. So when the above slides are displayed, I want the image to always be freshly loaded from the server and nothing to be fetched from the cache or anything like that. The size of the image in the slide should be adjustable in the code.
Can someone help me with this? Or does anyone have a sample PowerPoint that already contains a working macro or something that I just need to adapt? I've spent the whole day with ChatGPT and Google and nothing worked. I'm starting to despair. 2024 and PowerPoint can't display an image from a specific URL out of the box and without the help of scripts and add-ons...
I tried using ChatGPT, but the VBA code suggested to me didn't work. No image was inserted, the slide remained blank.
This is the code from ChatGPT:
Private Sub App_SlideShowNextSlide(ByVal Wn As SlideShowWindow)
Dim sld As slide
Dim shp As shape
Dim imgURL As String
' URL des Bildes
imgURL = "https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png"
' Auf die aktuelle Folie zugreifen
Set sld = Wn.View.Slide
' Bild mit dem Namen "LiveBild" löschen und neu hinzufügen
For Each shp In sld.Shapes
If shp.Name = "LiveBild" Then
shp.Delete
End If
Next shp
sld.Shapes.AddPicture imgURL, msoFalse, msoCTrue, 100, 100, -1, -1 ' Position und Größe anpassen
End Sub
Share
Improve this question
asked Nov 21, 2024 at 13:51
SvenSven
113 bronze badges
1 Answer
Reset to default 0There's a reason people describe ChatGPT as an but very drunk intern. It's given you code that might almost work as part of an installed add-in, but never in a PPTM.
It will work if you change the first line to
Sub OnSlideShowPageChange(ByVal Wn As SlideShowWindow)
but it'll put your image on every page. You then need to modify the code to have it work only if the newly viewed page is one of the ones you're after. Here's a modified version that only puts the image on slide 2:
Option Explicit
Sub OnSlideShowPageChange(ByVal Wn As SlideShowWindow)
Dim sld As Slide
Dim shp As Shape
Dim imgURL As String
' URL des Bildes
imgURL = "https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png"
' Auf die aktuelle Folie zugreifen
Set sld = Wn.View.Slide
' DELETE any image already there, regardless of slide number
' Bild mit dem Namen "LiveBild" löschen und neu hinzufügen
For Each shp In sld.Shapes
If shp.Name = "LiveBild" Then
shp.Delete
End If
Next shp
If sld.SlideIndex = 2 Then
set shp = sld.Shapes.AddPicture imgURL, msoFalse, msoCTrue, 100, 100, -1, -1 ' Position und Größe anpassen
shp.Name = "LiveBild"
End If
End Sub
本文标签: vbaFresh loading and insert image from WebserverStack Overflow
版权声明:本文标题:vba - Fresh loading and insert image from Webserver - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736310291a1934324.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论