Exporting to PowerPoint

U

Ugleeduck

Hello all,
Thanks in advance for reading my post. I'm trying to add a feature
that'll allow users of my spreadsheet to select and export a sheet to
a PowerPoint slide.
A combo box shows all the available sheets and copy + pastes the
selected range ( active range) to a PowerPoint slide. The code works
fine in a " standalone" mode. Meaning, I tried the code in a workbook
that didn't have any other subroutines/macros or forms and it works
fine. But, when I add it to another workbook that has many other
macros and forms, I keep getting numerous errors. The errors that I
get are...

1st error:
--------------
An outgoing call cannot be made since teh application is dispatching
an input-synchronus call.

2nd error:
-------------
invalid procedure call or argument

3rd error. ( doesn't happen always)
Cannot access network


Here's the code for the form
---------------------------------

Private Sub UserForm_Initialize()

With frmSelectReport2Export2PPT
.Caption = "Select Report To Export To PowerPoint"
.ForeColor = &H8000000E
.BackColor = &H80000001
.Font.Bold = True
.StartUpPosition = 2 'center screen
.Height = 157.5
.Width = 355.5
End With


With cmbSelectReport
.ForeColor = &H8000000E
.BackColor = &H80000001
.Font.Bold = True
.Height = 24
.Width = 174
.Top = 18
.Left = 162
.RowSource = "VBA_Data!ReportList"
'the range reportlist contains a list of all worksheets
End With

With cmdCancel
.Caption = "Cancel"
.ForeColor = &H8000000E
.BackColor = &H80000001
.Font.Bold = True
.Height = 24
.Width = 84
.Top = 84
.Left = 252.05
End With



Private Sub cmdContinue_Click()
'Application.ScreenUpdating = False
Unload Me
strSheetName = cmbSelectReport.Value



Sheets(strSheetName).Select


'range b12 is present in almost every report
Range("B12").Select
Selection.CurrentRegion.Select

Export2PPT
Application.ScreenUpdating = True

End Sub



Here's the code for the macro.....
----------------------------------


Sub Export2PPT()
'saves selected sheet as an PowerPoint slide.
'the sheet needs to be selected first.

Selection.Copy
Dim oPpoint As PowerPoint.Application
On Error Resume Next
Set oPpoint = GetObject(, "PowerPoint.Application")
On Error Resume Next

If oPpoint Is Nothing Then
Set oPpoint = CreateObject("PowerPoint.Application")
oPpoint.Activate
oPpoint.Visible = msoTrue
End If
'oPpoint.Visible = msoTrue
On Error Resume Next

With oPpoint
If .Presentations.Count = 0 Then
.Presentations.Add WithWindow:=msoTrue
End If
.ActiveWindow.View.GotoSlide
Index:=.ActivePresentation.Slides.Add(Index:=.ActivePresentation.Slides.Count
+ 1, Layout:=ppLayoutBlank).SlideIndex
.ActiveWindow.View.Paste
With .ActiveWindow.Selection.ShapeRange
.LockAspectRatio = msoFalse
.Width = oPpoint.ActivePresentation.PageSetup.SlideWidth
.Height = oPpoint.ActivePresentation.PageSetup.SlideHeight
.Top = 0
.Left = 0
End With
End With
Application.CutCopyMode = False


Application.ScreenUpdating = True

End Sub



Any idea what's causing this?


Thanks!
A. Rahman
 

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