G
Guest
Hello All,
I am trying to get some code to work that acts on an embedded worksheets
from powerpoint. With Steves help, it is mostly working. For some reason I
cannot get it to all come together. The code that follows is in a PPT with
several slides and some of the slides have msoEmbeddedOLEObjects (the
worksheets) and the second proceedure is called to act on the
msoEmbeddedOLEObjects. Can someone tell me where my errors are in this code?
Any help is greatly appreciated!
Sub Tag_n_Enumerate_Shapes()
Dim oSl As Slide
Dim oSh As Shape
Dim iShpaes As Integer
Dim iOLEShapes As Integer
For Each oSl In ActivePresentation.Slides
For Each oSh In oSl.Shapes
oSh.Tags.Add "TEST_TAG_NAME", "YadaYadaYada"
' You wanted a count of the shapes so:
iShapes = iShapes + 1
' Is it an OLEembedded thingie?
If oSh.Type = msoEmbeddedOLEObject Then
' Plug in Jon Peltiers's code here
' Increment the counter. Counts based on the if statement.
iOLEShapes = iOLEShapes + 1
'*********This is the code line I get the error on.***************
ActiveWindow.Selection.SlideRange.Shapes("Object 5").Select
ActiveWindow.Selection.ShapeRange.OLEFormat.DoVerb Index:=1
ActiveWindow.Selection.Unselect
'Call the ncmAgeCounter to do it's work
Application.Run "nmcAgeCounter"
End If
Next oSh
Next oSl
' and show the results:
MsgBox "There were " & CStr(i) & " shapes of which " _
& CStr(lOLEShapes) & " were OLE embedded objects."
End Sub
Sub nmcAgeCounter()
Dim briefDate As String
Dim lastCell
briefDate = InputBox("Please provide the date that this data will be
briefed." _
& Chr(10) & "format for the briefing date input is ""mm/dd/yyyy"".", _
"NMC Age Counter (MTC TECHNOLOGIES Inc.)")
If briefDate = "" Then
MsgBox "You must provide valid date that" _
& Chr(10) & "is equal to or greater than todays date!" _
& Chr(10) & "This program will close. Please try again.", 16, _
"NMC Age Counter (MTC TECHNOLOGIES Inc.)"
Exit Sub
ElseIf briefDate < Date Then
MsgBox "You must provide valid date that" _
& Chr(10) & "is equal to or greater than todays date!" _
& Chr(10) & "This program will close. Please try again.", 16, _
"NMC Age Counter (MTC TECHNOLOGIES Inc.)"
Exit Sub
End If
Set lastCell = Range("G65536").End(xlUp)
Columns("G:G").NumberFormat = "0"
Range("G5").FormulaR1C1 = "=IF(RC[-2]<>"""",DATE(2005,4,10)-RC[-2],"""")"
Range("G5").AutoFill Destination:=Range("G5", lastCell),
Type:=xlFillDefault
Range("A1").Select
End Sub
I am trying to get some code to work that acts on an embedded worksheets
from powerpoint. With Steves help, it is mostly working. For some reason I
cannot get it to all come together. The code that follows is in a PPT with
several slides and some of the slides have msoEmbeddedOLEObjects (the
worksheets) and the second proceedure is called to act on the
msoEmbeddedOLEObjects. Can someone tell me where my errors are in this code?
Any help is greatly appreciated!
Sub Tag_n_Enumerate_Shapes()
Dim oSl As Slide
Dim oSh As Shape
Dim iShpaes As Integer
Dim iOLEShapes As Integer
For Each oSl In ActivePresentation.Slides
For Each oSh In oSl.Shapes
oSh.Tags.Add "TEST_TAG_NAME", "YadaYadaYada"
' You wanted a count of the shapes so:
iShapes = iShapes + 1
' Is it an OLEembedded thingie?
If oSh.Type = msoEmbeddedOLEObject Then
' Plug in Jon Peltiers's code here
' Increment the counter. Counts based on the if statement.
iOLEShapes = iOLEShapes + 1
'*********This is the code line I get the error on.***************
ActiveWindow.Selection.SlideRange.Shapes("Object 5").Select
ActiveWindow.Selection.ShapeRange.OLEFormat.DoVerb Index:=1
ActiveWindow.Selection.Unselect
'Call the ncmAgeCounter to do it's work
Application.Run "nmcAgeCounter"
End If
Next oSh
Next oSl
' and show the results:
MsgBox "There were " & CStr(i) & " shapes of which " _
& CStr(lOLEShapes) & " were OLE embedded objects."
End Sub
Sub nmcAgeCounter()
Dim briefDate As String
Dim lastCell
briefDate = InputBox("Please provide the date that this data will be
briefed." _
& Chr(10) & "format for the briefing date input is ""mm/dd/yyyy"".", _
"NMC Age Counter (MTC TECHNOLOGIES Inc.)")
If briefDate = "" Then
MsgBox "You must provide valid date that" _
& Chr(10) & "is equal to or greater than todays date!" _
& Chr(10) & "This program will close. Please try again.", 16, _
"NMC Age Counter (MTC TECHNOLOGIES Inc.)"
Exit Sub
ElseIf briefDate < Date Then
MsgBox "You must provide valid date that" _
& Chr(10) & "is equal to or greater than todays date!" _
& Chr(10) & "This program will close. Please try again.", 16, _
"NMC Age Counter (MTC TECHNOLOGIES Inc.)"
Exit Sub
End If
Set lastCell = Range("G65536").End(xlUp)
Columns("G:G").NumberFormat = "0"
Range("G5").FormulaR1C1 = "=IF(RC[-2]<>"""",DATE(2005,4,10)-RC[-2],"""")"
Range("G5").AutoFill Destination:=Range("G5", lastCell),
Type:=xlFillDefault
Range("A1").Select
End Sub