PDA

View Full Version : Set Focus On Excel Instead Of Powerpoint



dwypen
08-07-2008, 12:59 PM
When I click on a command button on my userform to export my tables and Charts from Excel to Powerpoint, the screen focus is on Powerpoint instead of the userform.
And since there are more than 20 slides, it might take up to 20 secs to populate the slides. If an user clicks on any of the slides during that 20 secs, there will be an error msg and the running macro will be forced to end.

Is it possible to keep the screen focus on Excel instead of PPT while the slides are generating?

Thanks in advance!!!

Below is the coding I used for exporting data from Excel to PPT:

Sub Copy_Paste_to_PowerPoint()

Dim objPPT As Object, shtTemp As Object
Dim objShape As Shape
Dim ppSlide As PowerPoint.Slide
Dim ppSlideNum As Integer
Dim SheetName1 As String
Dim RangeName1 As String
Dim file_name As Variant, i As Integer

SheetName1 = "xxx"
RangeName1 = "xxx"

On Error Resume Next
Set objPPT = GetObject(, "PowerPoint.Application")
On Error Goto 0

On Error Goto NewPPT
Const PRES_FULL_PATH As String = "C:\xxx.ppt"
Set objPPT = CreateObject("Powerpoint.application")
objPPT.Visible = True
objPPT.Presentations.Open PRES_FULL_PATH
ppSlideNum = 3
objPPT.ActiveWindow.View.GotoSlide (ppSlideNum)
Set ppSlide = objPPT.ActivePresentation.Slides(ppSlideNum)
Worksheets(SheetName1). Range(RangeName1).Copy
ppSlide.Shapes.PasteSpecial(ppPasteHTML, link:=RangeLink).Select
.........

Kenneth Hobs
08-07-2008, 01:16 PM
I guess you could:

Appactivate application.Caption

You may not need Select. You may be able to set Visible=False or minimize ppt.