vbanovice123
Board Regular
- Joined
- Apr 15, 2011
- Messages
- 91
Hi,
part of the code is pasted below. I am trying to reference a slide by it's name instead of number while copy and paste into power point rom excel for a data table range. The functionality works when power point slide is referenced by slide number. But when referenced by name, I get an error.
I stepped through the code by setting breakpoints. I see a value of "HFI" for the slide in the copy_range function.
I declared the variable as a string as below: How can I resolve the error?
Dim slidename As String
I get the below:
Run Time error 13. Type mismatch.
Public Function copy_range(sheet, rngname, slide, arheight, arwidth, artop, arleft, vscale)
Sheets(sheet).Select
'Cells(rowStart, columnStart).Resize(row_count, columnCount).Select
Range(rngname).Select
' Make sure a range is selected
If Not TypeName(Selection) = "Range" Then
MsgBox "Please select a worksheet range and try again.", vbExclamation, _
"No Range Selected"
Else
' Reference existing instance of PowerPoint
Set PPApp = GetObject(, "Powerpoint.Application")
' Reference active presentation
Set PPPres = PPApp.ActivePresentation
PPApp.ActiveWindow.ViewType = ppViewSlide
'PPApp.ActiveWindow.View.GotoSlide (slide)
'PPApp.ActiveWindow.View.GotoSlide (slide)
PPApp.ActiveWindow.View.GotoSlide (slide)
' Reference active slide
Set PPSlide = PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)
Sub Copy2PowerPoint2()
Application.ScreenUpdating = False
'Dim slidenum As Integer
Dim slidename As String
Dim PPTM As PowerPoint.Application
Set PPTM = New PowerPoint.Application
PPTM.Visible = True
PPTM.Presentations.Open Filename:="F:\Focus\Test\OnePagersTemplates_CopyPasteProject\OnePagers_Templates\OriginationsMonitorPackage.pptm"
'slidenum = 11
'HFI
'copy_range(sheet, rngname, slide, aheight, awidth, atop, aleft, vscale)
'copy_range "HFI", "HFIYearQtr", slidenum, arheight, arwidth, artop, arleft, 1
slidename = "HFI"
'HFI
'copy_range(sheet, rngname, slide, aheight, awidth, atop, aleft, vscale)
copy_range "HFI", "HFIYearQtr", slidename, arheight, arwidth, artop, arleft, 1
part of the code is pasted below. I am trying to reference a slide by it's name instead of number while copy and paste into power point rom excel for a data table range. The functionality works when power point slide is referenced by slide number. But when referenced by name, I get an error.
I stepped through the code by setting breakpoints. I see a value of "HFI" for the slide in the copy_range function.
I declared the variable as a string as below: How can I resolve the error?
Dim slidename As String
I get the below:
Run Time error 13. Type mismatch.
Public Function copy_range(sheet, rngname, slide, arheight, arwidth, artop, arleft, vscale)
Sheets(sheet).Select
'Cells(rowStart, columnStart).Resize(row_count, columnCount).Select
Range(rngname).Select
' Make sure a range is selected
If Not TypeName(Selection) = "Range" Then
MsgBox "Please select a worksheet range and try again.", vbExclamation, _
"No Range Selected"
Else
' Reference existing instance of PowerPoint
Set PPApp = GetObject(, "Powerpoint.Application")
' Reference active presentation
Set PPPres = PPApp.ActivePresentation
PPApp.ActiveWindow.ViewType = ppViewSlide
'PPApp.ActiveWindow.View.GotoSlide (slide)
'PPApp.ActiveWindow.View.GotoSlide (slide)
PPApp.ActiveWindow.View.GotoSlide (slide)
' Reference active slide
Set PPSlide = PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)
Sub Copy2PowerPoint2()
Application.ScreenUpdating = False
'Dim slidenum As Integer
Dim slidename As String
Dim PPTM As PowerPoint.Application
Set PPTM = New PowerPoint.Application
PPTM.Visible = True
PPTM.Presentations.Open Filename:="F:\Focus\Test\OnePagersTemplates_CopyPasteProject\OnePagers_Templates\OriginationsMonitorPackage.pptm"
'slidenum = 11
'HFI
'copy_range(sheet, rngname, slide, aheight, awidth, atop, aleft, vscale)
'copy_range "HFI", "HFIYearQtr", slidenum, arheight, arwidth, artop, arleft, 1
slidename = "HFI"
'HFI
'copy_range(sheet, rngname, slide, aheight, awidth, atop, aleft, vscale)
copy_range "HFI", "HFIYearQtr", slidename, arheight, arwidth, artop, arleft, 1