VB AddPicutre in PowerPoint

D

Donald

I've written numerous Visual Basic 6.0 routines to automate the use of
PowerPoint and to interface between an in-house package and PowerPoint. One
thing I do is use the AddPicture method to place an EMF file into
PowerPoint. The problem is, even though I tell the method not to
LinktoFile, the EMF file remains open while PowerPoint is running. These
EMF files I create for loading into PowerPoint can't be deleted until
PowerPoint itself is closed, not just the single presentation.

Of course, when I reopen the presentation I see temporary (mso*.emf) files
created by PowerPoint, but these files don't cause problems with my VB
routines. Does anyone know of a way to close the links pictures short of
shutting down PowerPoint?

Sincerely,

Donald G Plugge
System Manager
NIH/NCI/EIB Flow Cytometry
(301)435-6429
435-6429
 
M

Mel Arquiza

Hi Donald,

See if this VB below works for you.

Option Explicit
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub Tmr1()
'Tmr stands for Timer
'isRunning stores the current state of the macro
'TRUE = Running; FALSE = Idle

Static isRunning As Boolean
If isRunning = True Then
End
Else
isRunning = True
Dim TMinus As Integer
Dim xtime As Date
xtime = Now

'On Slide 1

With ActivePresentation.Slides(1)

TMinus = 60

Do While (TMinus > -1)

' Suspend program execution for 1 second (1000 milliseconds)

Sleep 1000

xtime = Now

TMinus = TMinus - 50

' Very crucial else the display won't refresh itself

DoEvents
Loop


' 3-2-1-0 Blast off and move to the next slide or any slide for that
matter

SlideShowWindows(1).View.GotoSlide (2)
Call Tmr2
isRunning = False

End

End With
End If

End Sub

Sub Tmr2()

'Tmr stands for Timer
'isRunning stores the current state of the macro
'TRUE = Running; FALSE = Idle

Static isRunning As Boolean
If isRunning = True Then
End
Else
isRunning = True
Dim TMinus As Integer
Dim xtime As Date
xtime = Now

'On Slide 1

With ActivePresentation.Slides(2)

TMinus = 60

Do While (TMinus > -1)

' Suspend program execution for 1 second (1000 milliseconds)

Sleep 1000

xtime = Now

TMinus = TMinus - 50

' Very crucial else the display won't refresh itself

DoEvents
Loop


' 3-2-1-0 Blast off and move to the next slide or any slide for that
matter

Application.Run "Mel1"

Sleep 2000

Application.Run "Mel2"
isRunning = False

End

End With
End If

End Sub

'Code opening Presentation No_2.ppt file
Sub Mel1()
Dim file As String
file = "Presentation No_2.ppt"
Call PowerPoint.Presentations.Open(file, msoFalse, msoFalse, msoCTrue)
Application.ActivePresentation.SlideShowSettings.Run
End Sub

'Code opening Presenation No_1.ppt file
Sub Mel2()
Dim file As String
file = "Presentation No_1.ppt"
Call PowerPoint.Presentations.Open(file, msoFalse, msoFalse, msoCTrue)
Application.ActivePresentation.SlideShowSettings.Run
SlideShowWindows(1).View.GotoSlide (3)
End Sub

Hope it helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top