Forum Discussion

M_Salman_Jabbar's avatar
M_Salman_Jabbar
Copper Contributor
Jan 24, 2022

Vba to record PowerPoint Slidshow Timing Not Working for MAc

Hello there,

 

I am wondering if someone can help me improving this code to make it work for MAC. Here is the code to measure the time b/w entering PowerPoint in Slideshow mode and exiting from slideshow mode. It records the time period in seconds and stores in in Excel file on my hard Drive.

 

The main Problem is it doesn't seem to work after I've moved from Windows Operating System to Mac Operating system. Moreover, Neither is records the timing nor generates any Error and that's why I can't figure out where is the problem in the Code.

 

Here is the Code:

Dim slideShowRunning As Boolean
Dim counter As Integer
Dim st As Date
Dim i As Integer
Dim sttime As Date
Dim oxlapp As Object
Dim oxlwb As Object
Dim oxlws As Object
Dim edtime As Date


Sub SlideShowBegin(ByVal Wn As SlideShowWindow)

st = Date
sttime = Time

counter = 0
Debug.Print " works;1 "
Set oxlapp = CreateObject("Excel.Application")
Debug.Print " works; 2"
oxlapp.Visible = False
Debug.Print " works; 3"

'Set oxlwb = oxlapp.Workbooks.Open(ActivePresentation.Path & "\" & "record.xlsx")
Set oxlwb = oxlapp.Workbooks.Open(ActivePresentation.Path & Application.PathSeparator & "record.xlsx")
Debug.Print " works; 4"
Set oxlws = oxlwb.Sheets("TimeRecord")
Debug.Print " works; 5"
i = oxlws.Range("A99919").End(-4162).Row
oxlws.Range("A1").Offset(i, 0).Value = st
oxlws.Range("A1").Offset(i, 1).Value = sttime
Debug.Print " works; 6"
End Sub


Sub check()

End Sub

Public Sub OnSlideShowPageChange(ByVal Wn As SlideShowWindow)
If TypeName(slideShowRunning) = "Empty" Or slideShowRunning = False Then
slideShowRunning = True
SlideShowBegin Wn
End If
End Sub


Public Sub OnSlideShowTerminate(ByVal Wn As SlideShowWindow)
Name = Application.ActivePresentation.Name
slideShowRunning = False
edtime = Time
Debug.Print " works; 7"
ivalue = DateDiff("s", sttime, edtime)
Debug.Print ivalue
oxlws.Range("A1").Offset(i, 2).Value = edtime
oxlws.Range("A1").Offset(i, 3).Value = ivalue
oxlws.Range("A1").Offset(i, 4).Value = Name
Debug.Print " works; 9"

oxlapp.DisplayAlerts = False
Debug.Print " works; 10"
oxlwb.Save
Debug.Print " works; 11"
' oxlwb.Close
oxlapp.Visible = True
Debug.Print " works; 12"
oxlapp.DisplayAlerts = True

Debug.Print " works; 13"

End Sub

 

Any Help would be much appreciated.

3 Replies

  • NowshadAhmed's avatar
    NowshadAhmed
    Iron Contributor
    And which version of Office are you using in Mac? Earlier versions do not support macros and vbas. It has to be 2016 or later.
    • M_Salman_Jabbar's avatar
      M_Salman_Jabbar
      Copper Contributor
      My version is MS Office 365
      And I have changed the code by converting the FowradSlahes. And it still not working.
  • NowshadAhmed's avatar
    NowshadAhmed
    Iron Contributor
    For start: Mac uses Forward Slash ("/") instead of Backward Slash ("\) for paths.
    Your macro indicates "\". See if changing that helps.

    Also vba is not strong in Mac as it is in windows (obviously).

Resources