determining current version of PowerPoint

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?R2VvcmdlQXRraW5z?=

    #1

    determining current version of PowerPoint

    Greetings!
    I wrote a small Exe that simply runs Shell to load PowerPoint and launch a
    particular file, depending on the day of the week. However, it was set up for
    office 2003 (I naively hardcoded the path) and I also used Shell. Does
    anybody have a snipped showing a more efficient method for launching a
    Powerpoint file, regardless of which version of Office is running?

    My current, ineffecient code:
    Sub main()
    Try
    Dim ps1 As New PermissionSet(P ermissionState. Unrestricted)
    ps1.Demand()
    Dim MyDate As Date
    Dim DayOfWeek As Integer

    MyDate = Today
    DayOfWeek = Weekday(MyDate)

    ' Launch the powerpoint file for the current day of the week.
    Select Case DayOfWeek
    Case 1
    Shell("""C:\Pro gram Files\Microsoft
    Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Sunday.ppt""" )
    Case 2
    Shell("""C:\Pro gram Files\Microsoft
    Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Monday.ppt""" )
    Case 3
    Shell("""C:\Pro gram Files\Microsoft
    Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Tuesday.ppt"" ")
    Case 4
    Shell("""C:\Pro gram Files\Microsoft
    Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Wednesday.ppt """)
    Case 5
    Shell("""C:\Pro gram Files\Microsoft
    Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Thursday.ppt" "")
    Case 6
    Shell("""C:\Pro gram Files\Microsoft
    Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Friday.ppt""" )
    Case 7
    Shell("""C:\Pro gram Files\Microsoft
    Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Saturday.ppt" "")
    End Select
    Catch e As SecurityExcepti on
    MsgBox(e.Messag e)
    End Try
    End
    End Sub

    Thanks for any advise!
    George Atkins

  • Newbie Coder

    #2
    Re: determining current version of PowerPoint

    George,

    Here's a way to do it:

    Imports Microsoft.Win32
    Imports System.Diagnost ics.Process

    #Region "Get PowerPoint Path"

    Private Function GetPowerPointPa th() As String
    Dim reg As RegistryKey
    Try
    reg =
    Registry.LocalM achine.OpenSubK ey("SOFTWARE\Mi crosoft\Windows \CurrentVersion \App
    Paths\powerpnt. exe", False)
    Dim strShortPath As String = reg.GetValue("" , "")
    reg.Close()
    Return strShortPath
    Catch ex As Exception
    ' Some error handling here
    End Try
    End Function

    #End Region

    #Region "Get Day Of Week"

    Private Function GetDayOfWeek() As String
    Dim dt As DateTime = DateTime.Today
    Return dt.DayOfWeek.To String
    End Function

    #End Region

    #Region "Run PowerPoint Presentation"

    Private Sub RunPowerPointPr esentation()
    Dim strPPT As String = "C:\PPTs" & "\" & GetDayOfWeek() & ".ppt"
    Dim psi As New ProcessStartInf o(GetPowerPoint Path())
    Try
    With psi
    .Arguments = "/s " & strPPT
    .WindowStyle = ProcessWindowSt yle.Maximized
    End With
    Process.Start(p si)
    Catch ex As Exception
    ' Error Handling Here
    End Try
    End Sub

    I have chosen 'C:\PPTs' as the path I stored the PowerPoint files in

    Hope this helps,

    --
    Newbie Coder
    (It's just a name)



    "GeorgeAtki ns" <GeorgeAtkins@d iscussions.micr osoft.comwrote in message
    news:72827EEC-899E-429E-A6A8-40B2A764FE00@mi crosoft.com...
    Greetings!
    I wrote a small Exe that simply runs Shell to load PowerPoint and launch a
    particular file, depending on the day of the week. However, it was set up for
    office 2003 (I naively hardcoded the path) and I also used Shell. Does
    anybody have a snipped showing a more efficient method for launching a
    Powerpoint file, regardless of which version of Office is running?
    >
    My current, ineffecient code:
    Sub main()
    Try
    Dim ps1 As New PermissionSet(P ermissionState. Unrestricted)
    ps1.Demand()
    Dim MyDate As Date
    Dim DayOfWeek As Integer
    >
    MyDate = Today
    DayOfWeek = Weekday(MyDate)
    >
    ' Launch the powerpoint file for the current day of the week.
    Select Case DayOfWeek
    Case 1
    Shell("""C:\Pro gram Files\Microsoft
    Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Sunday.ppt""" )
    Case 2
    Shell("""C:\Pro gram Files\Microsoft
    Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Monday.ppt""" )
    Case 3
    Shell("""C:\Pro gram Files\Microsoft
    Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Tuesday.ppt"" ")
    Case 4
    Shell("""C:\Pro gram Files\Microsoft
    Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Wednesday.ppt """)
    Case 5
    Shell("""C:\Pro gram Files\Microsoft
    Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Thursday.ppt" "")
    Case 6
    Shell("""C:\Pro gram Files\Microsoft
    Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Friday.ppt""" )
    Case 7
    Shell("""C:\Pro gram Files\Microsoft
    Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Saturday.ppt" "")
    End Select
    Catch e As SecurityExcepti on
    MsgBox(e.Messag e)
    End Try
    End
    End Sub
    >
    Thanks for any advise!
    George Atkins
    >

    Comment

    • =?Utf-8?B?R2VvcmdlQXRraW5z?=

      #3
      Re: determining current version of PowerPoint

      Sorry that I missed your post; I forgot to mark the Notify box and work has
      kept me busy. I'll try this out when I get back to work, first thing. Thanks
      a whole lot for the solution.
      george atkins

      "Newbie Coder" wrote:
      George,
      >
      Here's a way to do it:
      >
      Imports Microsoft.Win32
      Imports System.Diagnost ics.Process
      >
      #Region "Get PowerPoint Path"
      >
      Private Function GetPowerPointPa th() As String
      Dim reg As RegistryKey
      Try
      reg =
      Registry.LocalM achine.OpenSubK ey("SOFTWARE\Mi crosoft\Windows \CurrentVersion \App
      Paths\powerpnt. exe", False)
      Dim strShortPath As String = reg.GetValue("" , "")
      reg.Close()
      Return strShortPath
      Catch ex As Exception
      ' Some error handling here
      End Try
      End Function
      >
      #End Region
      >
      #Region "Get Day Of Week"
      >
      Private Function GetDayOfWeek() As String
      Dim dt As DateTime = DateTime.Today
      Return dt.DayOfWeek.To String
      End Function
      >
      #End Region
      >
      #Region "Run PowerPoint Presentation"
      >
      Private Sub RunPowerPointPr esentation()
      Dim strPPT As String = "C:\PPTs" & "\" & GetDayOfWeek() & ".ppt"
      Dim psi As New ProcessStartInf o(GetPowerPoint Path())
      Try
      With psi
      .Arguments = "/s " & strPPT
      .WindowStyle = ProcessWindowSt yle.Maximized
      End With
      Process.Start(p si)
      Catch ex As Exception
      ' Error Handling Here
      End Try
      End Sub
      >
      I have chosen 'C:\PPTs' as the path I stored the PowerPoint files in
      >
      Hope this helps,
      >
      --
      Newbie Coder
      (It's just a name)
      >
      >
      >
      "GeorgeAtki ns" <GeorgeAtkins@d iscussions.micr osoft.comwrote in message
      news:72827EEC-899E-429E-A6A8-40B2A764FE00@mi crosoft.com...
      Greetings!
      I wrote a small Exe that simply runs Shell to load PowerPoint and launch a
      particular file, depending on the day of the week. However, it was set up for
      office 2003 (I naively hardcoded the path) and I also used Shell. Does
      anybody have a snipped showing a more efficient method for launching a
      Powerpoint file, regardless of which version of Office is running?

      My current, ineffecient code:
      Sub main()
      Try
      Dim ps1 As New PermissionSet(P ermissionState. Unrestricted)
      ps1.Demand()
      Dim MyDate As Date
      Dim DayOfWeek As Integer

      MyDate = Today
      DayOfWeek = Weekday(MyDate)

      ' Launch the powerpoint file for the current day of the week.
      Select Case DayOfWeek
      Case 1
      Shell("""C:\Pro gram Files\Microsoft
      Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Sunday.ppt""" )
      Case 2
      Shell("""C:\Pro gram Files\Microsoft
      Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Monday.ppt""" )
      Case 3
      Shell("""C:\Pro gram Files\Microsoft
      Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Tuesday.ppt"" ")
      Case 4
      Shell("""C:\Pro gram Files\Microsoft
      Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Wednesday.ppt """)
      Case 5
      Shell("""C:\Pro gram Files\Microsoft
      Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Thursday.ppt" "")
      Case 6
      Shell("""C:\Pro gram Files\Microsoft
      Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Friday.ppt""" )
      Case 7
      Shell("""C:\Pro gram Files\Microsoft
      Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Saturday.ppt" "")
      End Select
      Catch e As SecurityExcepti on
      MsgBox(e.Messag e)
      End Try
      End
      End Sub

      Thanks for any advise!
      George Atkins
      >
      >
      >

      Comment

      • =?Utf-8?B?R2VvcmdlQXRraW5z?=

        #4
        Re: determining current version of PowerPoint

        Thanks for the code. When I tried to run it, I received the following
        "warning" that prevents the code from running or compiling:

        "Warning 1 Function 'GetPowerPointP ath' doesn't return a value on all code
        paths. A null reference exception could occur at run time when the result is
        used."

        I'm running a standard installation of PowerPoint 2007 on an XP SP2 machine.
        Do you have any troubleshooting advise? I checked for the path in the
        Registry and it is correct.

        George

        "Newbie Coder" wrote:
        George,
        >
        Here's a way to do it:
        >
        Imports Microsoft.Win32
        Imports System.Diagnost ics.Process
        >
        #Region "Get PowerPoint Path"
        >
        Private Function GetPowerPointPa th() As String
        Dim reg As RegistryKey
        Try
        reg =
        Registry.LocalM achine.OpenSubK ey("SOFTWARE\Mi crosoft\Windows \CurrentVersion \App
        Paths\powerpnt. exe", False)
        Dim strShortPath As String = reg.GetValue("" , "")
        reg.Close()
        Return strShortPath
        Catch ex As Exception
        ' Some error handling here
        End Try
        End Function
        >
        #End Region
        >
        #Region "Get Day Of Week"
        >
        Private Function GetDayOfWeek() As String
        Dim dt As DateTime = DateTime.Today
        Return dt.DayOfWeek.To String
        End Function
        >
        #End Region
        >
        #Region "Run PowerPoint Presentation"
        >
        Private Sub RunPowerPointPr esentation()
        Dim strPPT As String = "C:\PPTs" & "\" & GetDayOfWeek() & ".ppt"
        Dim psi As New ProcessStartInf o(GetPowerPoint Path())
        Try
        With psi
        .Arguments = "/s " & strPPT
        .WindowStyle = ProcessWindowSt yle.Maximized
        End With
        Process.Start(p si)
        Catch ex As Exception
        ' Error Handling Here
        End Try
        End Sub
        >
        I have chosen 'C:\PPTs' as the path I stored the PowerPoint files in
        >
        Hope this helps,
        >
        --
        Newbie Coder
        (It's just a name)
        >
        >
        >
        "GeorgeAtki ns" <GeorgeAtkins@d iscussions.micr osoft.comwrote in message
        news:72827EEC-899E-429E-A6A8-40B2A764FE00@mi crosoft.com...
        Greetings!
        I wrote a small Exe that simply runs Shell to load PowerPoint and launch a
        particular file, depending on the day of the week. However, it was set up for
        office 2003 (I naively hardcoded the path) and I also used Shell. Does
        anybody have a snipped showing a more efficient method for launching a
        Powerpoint file, regardless of which version of Office is running?

        My current, ineffecient code:
        Sub main()
        Try
        Dim ps1 As New PermissionSet(P ermissionState. Unrestricted)
        ps1.Demand()
        Dim MyDate As Date
        Dim DayOfWeek As Integer

        MyDate = Today
        DayOfWeek = Weekday(MyDate)

        ' Launch the powerpoint file for the current day of the week.
        Select Case DayOfWeek
        Case 1
        Shell("""C:\Pro gram Files\Microsoft
        Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Sunday.ppt""" )
        Case 2
        Shell("""C:\Pro gram Files\Microsoft
        Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Monday.ppt""" )
        Case 3
        Shell("""C:\Pro gram Files\Microsoft
        Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Tuesday.ppt"" ")
        Case 4
        Shell("""C:\Pro gram Files\Microsoft
        Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Wednesday.ppt """)
        Case 5
        Shell("""C:\Pro gram Files\Microsoft
        Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Thursday.ppt" "")
        Case 6
        Shell("""C:\Pro gram Files\Microsoft
        Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Friday.ppt""" )
        Case 7
        Shell("""C:\Pro gram Files\Microsoft
        Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Saturday.ppt" "")
        End Select
        Catch e As SecurityExcepti on
        MsgBox(e.Messag e)
        End Try
        End
        End Sub

        Thanks for any advise!
        George Atkins
        >
        >
        >

        Comment

        • =?Utf-8?B?R2VvcmdlQXRraW5z?=

          #5
          Re: determining current version of PowerPoint

          Well, I think I may have an inkling of the problem.
          The function that determines the PPT path, returns the following string:
          "C:\PROGRA~1\MI CROS~2\Office12 \POWERPNT.EXE"

          Why Microsoft records these old-fashioned, truncated names is beyond me. But
          I believe the ~1 and ~2 syntax is what is causing the problem. I could edit
          the syntax, but as I'm going to run this on other machines, this is not a
          good solution.

          I revised the code to show: reg.GetValue("P ath", ""). This returns a valid,
          full path, but the code continues to fail with the warning previously
          reported.

          Any other ideas?
          George



          "Newbie Coder" wrote:
          George,
          >
          Here's a way to do it:
          >
          Imports Microsoft.Win32
          Imports System.Diagnost ics.Process
          >
          #Region "Get PowerPoint Path"
          >
          Private Function GetPowerPointPa th() As String
          Dim reg As RegistryKey
          Try
          reg =
          Registry.LocalM achine.OpenSubK ey("SOFTWARE\Mi crosoft\Windows \CurrentVersion \App
          Paths\powerpnt. exe", False)
          Dim strShortPath As String = reg.GetValue("" , "")
          reg.Close()
          Return strShortPath
          Catch ex As Exception
          ' Some error handling here
          End Try
          End Function
          >
          #End Region
          >
          #Region "Get Day Of Week"
          >
          Private Function GetDayOfWeek() As String
          Dim dt As DateTime = DateTime.Today
          Return dt.DayOfWeek.To String
          End Function
          >
          #End Region
          >
          #Region "Run PowerPoint Presentation"
          >
          Private Sub RunPowerPointPr esentation()
          Dim strPPT As String = "C:\PPTs" & "\" & GetDayOfWeek() & ".ppt"
          Dim psi As New ProcessStartInf o(GetPowerPoint Path())
          Try
          With psi
          .Arguments = "/s " & strPPT
          .WindowStyle = ProcessWindowSt yle.Maximized
          End With
          Process.Start(p si)
          Catch ex As Exception
          ' Error Handling Here
          End Try
          End Sub
          >
          I have chosen 'C:\PPTs' as the path I stored the PowerPoint files in
          >
          Hope this helps,
          >
          --
          Newbie Coder
          (It's just a name)
          >
          >
          >
          "GeorgeAtki ns" <GeorgeAtkins@d iscussions.micr osoft.comwrote in message
          news:72827EEC-899E-429E-A6A8-40B2A764FE00@mi crosoft.com...
          Greetings!
          I wrote a small Exe that simply runs Shell to load PowerPoint and launch a
          particular file, depending on the day of the week. However, it was set up for
          office 2003 (I naively hardcoded the path) and I also used Shell. Does
          anybody have a snipped showing a more efficient method for launching a
          Powerpoint file, regardless of which version of Office is running?

          My current, ineffecient code:
          Sub main()
          Try
          Dim ps1 As New PermissionSet(P ermissionState. Unrestricted)
          ps1.Demand()
          Dim MyDate As Date
          Dim DayOfWeek As Integer

          MyDate = Today
          DayOfWeek = Weekday(MyDate)

          ' Launch the powerpoint file for the current day of the week.
          Select Case DayOfWeek
          Case 1
          Shell("""C:\Pro gram Files\Microsoft
          Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Sunday.ppt""" )
          Case 2
          Shell("""C:\Pro gram Files\Microsoft
          Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Monday.ppt""" )
          Case 3
          Shell("""C:\Pro gram Files\Microsoft
          Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Tuesday.ppt"" ")
          Case 4
          Shell("""C:\Pro gram Files\Microsoft
          Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Wednesday.ppt """)
          Case 5
          Shell("""C:\Pro gram Files\Microsoft
          Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Thursday.ppt" "")
          Case 6
          Shell("""C:\Pro gram Files\Microsoft
          Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Friday.ppt""" )
          Case 7
          Shell("""C:\Pro gram Files\Microsoft
          Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() & "\Saturday.ppt" "")
          End Select
          Catch e As SecurityExcepti on
          MsgBox(e.Messag e)
          End Try
          End
          End Sub

          Thanks for any advise!
          George Atkins
          >
          >
          >

          Comment

          • Newbie Coder

            #6
            Re: determining current version of PowerPoint

            George,

            In my original code I wrote:

            GetValue("", "")

            This gets the default value & if doesn't exist returns "". You can change the
            second "" to the default path to MS Powerpoint, which will stop the error

            --
            Newbie Coder
            (It's just a name)

            "GeorgeAtki ns" <GeorgeAtkins@d iscussions.micr osoft.comwrote in message
            news:7C3A1A2B-B045-4054-9659-0F0FAF667690@mi crosoft.com...
            Thanks for the code. When I tried to run it, I received the following
            "warning" that prevents the code from running or compiling:
            >
            "Warning 1 Function 'GetPowerPointP ath' doesn't return a value on all code
            paths. A null reference exception could occur at run time when the result is
            used."
            >
            I'm running a standard installation of PowerPoint 2007 on an XP SP2 machine.
            Do you have any troubleshooting advise? I checked for the path in the
            Registry and it is correct.
            >
            George
            >
            "Newbie Coder" wrote:
            >
            George,

            Here's a way to do it:

            Imports Microsoft.Win32
            Imports System.Diagnost ics.Process

            #Region "Get PowerPoint Path"

            Private Function GetPowerPointPa th() As String
            Dim reg As RegistryKey
            Try
            reg =
            Registry.LocalM achine.OpenSubK ey("SOFTWARE\Mi crosoft\Windows \CurrentVersion \App
            Paths\powerpnt. exe", False)
            Dim strShortPath As String = reg.GetValue("" , "")
            reg.Close()
            Return strShortPath
            Catch ex As Exception
            ' Some error handling here
            End Try
            End Function

            #End Region

            #Region "Get Day Of Week"

            Private Function GetDayOfWeek() As String
            Dim dt As DateTime = DateTime.Today
            Return dt.DayOfWeek.To String
            End Function

            #End Region

            #Region "Run PowerPoint Presentation"

            Private Sub RunPowerPointPr esentation()
            Dim strPPT As String = "C:\PPTs" & "\" & GetDayOfWeek() & ".ppt"
            Dim psi As New ProcessStartInf o(GetPowerPoint Path())
            Try
            With psi
            .Arguments = "/s " & strPPT
            .WindowStyle = ProcessWindowSt yle.Maximized
            End With
            Process.Start(p si)
            Catch ex As Exception
            ' Error Handling Here
            End Try
            End Sub

            I have chosen 'C:\PPTs' as the path I stored the PowerPoint files in

            Hope this helps,

            --
            Newbie Coder
            (It's just a name)



            "GeorgeAtki ns" <GeorgeAtkins@d iscussions.micr osoft.comwrote in message
            news:72827EEC-899E-429E-A6A8-40B2A764FE00@mi crosoft.com...
            Greetings!
            I wrote a small Exe that simply runs Shell to load PowerPoint and launch a
            particular file, depending on the day of the week. However, it was set up
            for
            office 2003 (I naively hardcoded the path) and I also used Shell. Does
            anybody have a snipped showing a more efficient method for launching a
            Powerpoint file, regardless of which version of Office is running?
            >
            My current, ineffecient code:
            Sub main()
            Try
            Dim ps1 As New PermissionSet(P ermissionState. Unrestricted)
            ps1.Demand()
            Dim MyDate As Date
            Dim DayOfWeek As Integer
            >
            MyDate = Today
            DayOfWeek = Weekday(MyDate)
            >
            ' Launch the powerpoint file for the current day of the week.
            Select Case DayOfWeek
            Case 1
            Shell("""C:\Pro gram Files\Microsoft
            Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() &
            "\Sunday.ppt""" )
            Case 2
            Shell("""C:\Pro gram Files\Microsoft
            Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() &
            "\Monday.ppt""" )
            Case 3
            Shell("""C:\Pro gram Files\Microsoft
            Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() &
            "\Tuesday.ppt"" ")
            Case 4
            Shell("""C:\Pro gram Files\Microsoft
            Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() &
            "\Wednesday.ppt """)
            Case 5
            Shell("""C:\Pro gram Files\Microsoft
            Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() &
            "\Thursday.ppt" "")
            Case 6
            Shell("""C:\Pro gram Files\Microsoft
            Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() &
            "\Friday.ppt""" )
            Case 7
            Shell("""C:\Pro gram Files\Microsoft
            Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() &
            "\Saturday.ppt" "")
            End Select
            Catch e As SecurityExcepti on
            MsgBox(e.Messag e)
            End Try
            End
            End Sub
            >
            Thanks for any advise!
            George Atkins
            >

            Comment

            • Newbie Coder

              #7
              Re: determining current version of PowerPoint

              George,

              ' Import
              Imports System.IO

              To get the Long Path Name use this function:

              Public Shared Function GetLongPath(ByV al path As String) As String
              Dim root As String = System.IO.Path. GetPathRoot(pat h)
              Dim folders As String() = path.Substring( root.Length). _
              Split(System.IO .Path.Directory SeparatorChar)
              Dim res As String = root
              Dim name As String
              For Each name In folders
              Dim di = New DirectoryInfo(r es)
              Dim fsi As System.IO.FileS ystemInfo() = _
              di.GetFileSyste mInfos(name)
              If fsi.Length = 1 Then
              res = fsi(0).FullName
              Else
              ' Error handling here
              End If
              Next
              Return res
              End Function

              The above isn't my function but it works fine

              --
              Newbie Coder
              (It's just a name)



              "GeorgeAtki ns" <GeorgeAtkins@d iscussions.micr osoft.comwrote in message
              news:97B4C3C3-A9F5-475E-9A96-8C2D1582BBC1@mi crosoft.com...
              Well, I think I may have an inkling of the problem.
              The function that determines the PPT path, returns the following string:
              "C:\PROGRA~1\MI CROS~2\Office12 \POWERPNT.EXE"
              >
              Why Microsoft records these old-fashioned, truncated names is beyond me. But
              I believe the ~1 and ~2 syntax is what is causing the problem. I could edit
              the syntax, but as I'm going to run this on other machines, this is not a
              good solution.
              >
              I revised the code to show: reg.GetValue("P ath", ""). This returns a valid,
              full path, but the code continues to fail with the warning previously
              reported.
              >
              Any other ideas?
              George
              >
              >
              >
              "Newbie Coder" wrote:
              >
              George,

              Here's a way to do it:

              Imports Microsoft.Win32
              Imports System.Diagnost ics.Process

              #Region "Get PowerPoint Path"

              Private Function GetPowerPointPa th() As String
              Dim reg As RegistryKey
              Try
              reg =
              Registry.LocalM achine.OpenSubK ey("SOFTWARE\Mi crosoft\Windows \CurrentVersion \App
              Paths\powerpnt. exe", False)
              Dim strShortPath As String = reg.GetValue("" , "")
              reg.Close()
              Return strShortPath
              Catch ex As Exception
              ' Some error handling here
              End Try
              End Function

              #End Region

              #Region "Get Day Of Week"

              Private Function GetDayOfWeek() As String
              Dim dt As DateTime = DateTime.Today
              Return dt.DayOfWeek.To String
              End Function

              #End Region

              #Region "Run PowerPoint Presentation"

              Private Sub RunPowerPointPr esentation()
              Dim strPPT As String = "C:\PPTs" & "\" & GetDayOfWeek() & ".ppt"
              Dim psi As New ProcessStartInf o(GetPowerPoint Path())
              Try
              With psi
              .Arguments = "/s " & strPPT
              .WindowStyle = ProcessWindowSt yle.Maximized
              End With
              Process.Start(p si)
              Catch ex As Exception
              ' Error Handling Here
              End Try
              End Sub

              I have chosen 'C:\PPTs' as the path I stored the PowerPoint files in

              Hope this helps,

              --
              Newbie Coder
              (It's just a name)



              "GeorgeAtki ns" <GeorgeAtkins@d iscussions.micr osoft.comwrote in message
              news:72827EEC-899E-429E-A6A8-40B2A764FE00@mi crosoft.com...
              Greetings!
              I wrote a small Exe that simply runs Shell to load PowerPoint and launch a
              particular file, depending on the day of the week. However, it was set up
              for
              office 2003 (I naively hardcoded the path) and I also used Shell. Does
              anybody have a snipped showing a more efficient method for launching a
              Powerpoint file, regardless of which version of Office is running?
              >
              My current, ineffecient code:
              Sub main()
              Try
              Dim ps1 As New PermissionSet(P ermissionState. Unrestricted)
              ps1.Demand()
              Dim MyDate As Date
              Dim DayOfWeek As Integer
              >
              MyDate = Today
              DayOfWeek = Weekday(MyDate)
              >
              ' Launch the powerpoint file for the current day of the week.
              Select Case DayOfWeek
              Case 1
              Shell("""C:\Pro gram Files\Microsoft
              Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() &
              "\Sunday.ppt""" )
              Case 2
              Shell("""C:\Pro gram Files\Microsoft
              Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() &
              "\Monday.ppt""" )
              Case 3
              Shell("""C:\Pro gram Files\Microsoft
              Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() &
              "\Tuesday.ppt"" ")
              Case 4
              Shell("""C:\Pro gram Files\Microsoft
              Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() &
              "\Wednesday.ppt """)
              Case 5
              Shell("""C:\Pro gram Files\Microsoft
              Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() &
              "\Thursday.ppt" "")
              Case 6
              Shell("""C:\Pro gram Files\Microsoft
              Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() &
              "\Friday.ppt""" )
              Case 7
              Shell("""C:\Pro gram Files\Microsoft
              Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() &
              "\Saturday.ppt" "")
              End Select
              Catch e As SecurityExcepti on
              MsgBox(e.Messag e)
              End Try
              End
              End Sub
              >
              Thanks for any advise!
              George Atkins
              >

              Comment

              • =?Utf-8?B?R2VvcmdlQXRraW5z?=

                #8
                Re: determining current version of PowerPoint

                Thanks much for both tips. I'll plug this in. Have a nice weekend!
                George

                "Newbie Coder" wrote:
                George,
                >
                ' Import
                Imports System.IO
                >
                To get the Long Path Name use this function:
                >
                Public Shared Function GetLongPath(ByV al path As String) As String
                Dim root As String = System.IO.Path. GetPathRoot(pat h)
                Dim folders As String() = path.Substring( root.Length). _
                Split(System.IO .Path.Directory SeparatorChar)
                Dim res As String = root
                Dim name As String
                For Each name In folders
                Dim di = New DirectoryInfo(r es)
                Dim fsi As System.IO.FileS ystemInfo() = _
                di.GetFileSyste mInfos(name)
                If fsi.Length = 1 Then
                res = fsi(0).FullName
                Else
                ' Error handling here
                End If
                Next
                Return res
                End Function
                >
                The above isn't my function but it works fine
                >
                --
                Newbie Coder
                (It's just a name)
                >
                >
                >
                "GeorgeAtki ns" <GeorgeAtkins@d iscussions.micr osoft.comwrote in message
                news:97B4C3C3-A9F5-475E-9A96-8C2D1582BBC1@mi crosoft.com...
                Well, I think I may have an inkling of the problem.
                The function that determines the PPT path, returns the following string:
                "C:\PROGRA~1\MI CROS~2\Office12 \POWERPNT.EXE"

                Why Microsoft records these old-fashioned, truncated names is beyond me. But
                I believe the ~1 and ~2 syntax is what is causing the problem. I could edit
                the syntax, but as I'm going to run this on other machines, this is not a
                good solution.

                I revised the code to show: reg.GetValue("P ath", ""). This returns a valid,
                full path, but the code continues to fail with the warning previously
                reported.

                Any other ideas?
                George



                "Newbie Coder" wrote:
                George,
                >
                Here's a way to do it:
                >
                Imports Microsoft.Win32
                Imports System.Diagnost ics.Process
                >
                #Region "Get PowerPoint Path"
                >
                Private Function GetPowerPointPa th() As String
                Dim reg As RegistryKey
                Try
                reg =
                >
                Registry.LocalM achine.OpenSubK ey("SOFTWARE\Mi crosoft\Windows \CurrentVersion \App
                Paths\powerpnt. exe", False)
                Dim strShortPath As String = reg.GetValue("" , "")
                reg.Close()
                Return strShortPath
                Catch ex As Exception
                ' Some error handling here
                End Try
                End Function
                >
                #End Region
                >
                #Region "Get Day Of Week"
                >
                Private Function GetDayOfWeek() As String
                Dim dt As DateTime = DateTime.Today
                Return dt.DayOfWeek.To String
                End Function
                >
                #End Region
                >
                #Region "Run PowerPoint Presentation"
                >
                Private Sub RunPowerPointPr esentation()
                Dim strPPT As String = "C:\PPTs" & "\" & GetDayOfWeek() & ".ppt"
                Dim psi As New ProcessStartInf o(GetPowerPoint Path())
                Try
                With psi
                .Arguments = "/s " & strPPT
                .WindowStyle = ProcessWindowSt yle.Maximized
                End With
                Process.Start(p si)
                Catch ex As Exception
                ' Error Handling Here
                End Try
                End Sub
                >
                I have chosen 'C:\PPTs' as the path I stored the PowerPoint files in
                >
                Hope this helps,
                >
                --
                Newbie Coder
                (It's just a name)
                >
                >
                >
                "GeorgeAtki ns" <GeorgeAtkins@d iscussions.micr osoft.comwrote in message
                news:72827EEC-899E-429E-A6A8-40B2A764FE00@mi crosoft.com...
                Greetings!
                I wrote a small Exe that simply runs Shell to load PowerPoint and launch a
                particular file, depending on the day of the week. However, it was set up
                for
                office 2003 (I naively hardcoded the path) and I also used Shell. Does
                anybody have a snipped showing a more efficient method for launching a
                Powerpoint file, regardless of which version of Office is running?

                My current, ineffecient code:
                Sub main()
                Try
                Dim ps1 As New PermissionSet(P ermissionState. Unrestricted)
                ps1.Demand()
                Dim MyDate As Date
                Dim DayOfWeek As Integer

                MyDate = Today
                DayOfWeek = Weekday(MyDate)

                ' Launch the powerpoint file for the current day of the week.
                Select Case DayOfWeek
                Case 1
                Shell("""C:\Pro gram Files\Microsoft
                Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() &
                "\Sunday.ppt""" )
                Case 2
                Shell("""C:\Pro gram Files\Microsoft
                Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() &
                "\Monday.ppt""" )
                Case 3
                Shell("""C:\Pro gram Files\Microsoft
                Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() &
                "\Tuesday.ppt"" ")
                Case 4
                Shell("""C:\Pro gram Files\Microsoft
                Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() &
                "\Wednesday.ppt """)
                Case 5
                Shell("""C:\Pro gram Files\Microsoft
                Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() &
                "\Thursday.ppt" "")
                Case 6
                Shell("""C:\Pro gram Files\Microsoft
                Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() &
                "\Friday.ppt""" )
                Case 7
                Shell("""C:\Pro gram Files\Microsoft
                Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() &
                "\Saturday.ppt" "")
                End Select
                Catch e As SecurityExcepti on
                MsgBox(e.Messag e)
                End Try
                End
                End Sub

                Thanks for any advise!
                George Atkins

                >
                >
                >
                >
                >
                >

                Comment

                • Newbie Coder

                  #9
                  Re: determining current version of PowerPoint

                  George,

                  Have a great weekend too

                  --
                  Newbie Coder
                  (It's just a name)

                  "GeorgeAtki ns" <GeorgeAtkins@d iscussions.micr osoft.comwrote in message
                  news:D293EBF7-38F5-47CA-95C3-D88A75ACCD28@mi crosoft.com...
                  Thanks much for both tips. I'll plug this in. Have a nice weekend!
                  George
                  >
                  "Newbie Coder" wrote:
                  >
                  George,

                  ' Import
                  Imports System.IO

                  To get the Long Path Name use this function:

                  Public Shared Function GetLongPath(ByV al path As String) As String
                  Dim root As String = System.IO.Path. GetPathRoot(pat h)
                  Dim folders As String() = path.Substring( root.Length). _
                  Split(System.IO .Path.Directory SeparatorChar)
                  Dim res As String = root
                  Dim name As String
                  For Each name In folders
                  Dim di = New DirectoryInfo(r es)
                  Dim fsi As System.IO.FileS ystemInfo() = _
                  di.GetFileSyste mInfos(name)
                  If fsi.Length = 1 Then
                  res = fsi(0).FullName
                  Else
                  ' Error handling here
                  End If
                  Next
                  Return res
                  End Function

                  The above isn't my function but it works fine

                  --
                  Newbie Coder
                  (It's just a name)



                  "GeorgeAtki ns" <GeorgeAtkins@d iscussions.micr osoft.comwrote in message
                  news:97B4C3C3-A9F5-475E-9A96-8C2D1582BBC1@mi crosoft.com...
                  Well, I think I may have an inkling of the problem.
                  The function that determines the PPT path, returns the following string:
                  "C:\PROGRA~1\MI CROS~2\Office12 \POWERPNT.EXE"
                  >
                  Why Microsoft records these old-fashioned, truncated names is beyond me.
                  But
                  I believe the ~1 and ~2 syntax is what is causing the problem. I could
                  edit
                  the syntax, but as I'm going to run this on other machines, this is not a
                  good solution.
                  >
                  I revised the code to show: reg.GetValue("P ath", ""). This returns a
                  valid,
                  full path, but the code continues to fail with the warning previously
                  reported.
                  >
                  Any other ideas?
                  George
                  >
                  >
                  >
                  "Newbie Coder" wrote:
                  >
                  George,

                  Here's a way to do it:

                  Imports Microsoft.Win32
                  Imports System.Diagnost ics.Process

                  #Region "Get PowerPoint Path"

                  Private Function GetPowerPointPa th() As String
                  Dim reg As RegistryKey
                  Try
                  reg =
                  Registry.LocalM achine.OpenSubK ey("SOFTWARE\Mi crosoft\Windows \CurrentVersion \App
                  Paths\powerpnt. exe", False)
                  Dim strShortPath As String = reg.GetValue("" , "")
                  reg.Close()
                  Return strShortPath
                  Catch ex As Exception
                  ' Some error handling here
                  End Try
                  End Function

                  #End Region

                  #Region "Get Day Of Week"

                  Private Function GetDayOfWeek() As String
                  Dim dt As DateTime = DateTime.Today
                  Return dt.DayOfWeek.To String
                  End Function

                  #End Region

                  #Region "Run PowerPoint Presentation"

                  Private Sub RunPowerPointPr esentation()
                  Dim strPPT As String = "C:\PPTs" & "\" & GetDayOfWeek() & ".ppt"
                  Dim psi As New ProcessStartInf o(GetPowerPoint Path())
                  Try
                  With psi
                  .Arguments = "/s " & strPPT
                  .WindowStyle = ProcessWindowSt yle.Maximized
                  End With
                  Process.Start(p si)
                  Catch ex As Exception
                  ' Error Handling Here
                  End Try
                  End Sub

                  I have chosen 'C:\PPTs' as the path I stored the PowerPoint files in

                  Hope this helps,

                  --
                  Newbie Coder
                  (It's just a name)



                  "GeorgeAtki ns" <GeorgeAtkins@d iscussions.micr osoft.comwrote in message
                  news:72827EEC-899E-429E-A6A8-40B2A764FE00@mi crosoft.com...
                  Greetings!
                  I wrote a small Exe that simply runs Shell to load PowerPoint and
                  launch a
                  particular file, depending on the day of the week. However, it was set
                  up
                  for
                  office 2003 (I naively hardcoded the path) and I also used Shell. Does
                  anybody have a snipped showing a more efficient method for launching a
                  Powerpoint file, regardless of which version of Office is running?
                  >
                  My current, ineffecient code:
                  Sub main()
                  Try
                  Dim ps1 As New PermissionSet(P ermissionState. Unrestricted)
                  ps1.Demand()
                  Dim MyDate As Date
                  Dim DayOfWeek As Integer
                  >
                  MyDate = Today
                  DayOfWeek = Weekday(MyDate)
                  >
                  ' Launch the powerpoint file for the current day of the
                  week.
                  Select Case DayOfWeek
                  Case 1
                  Shell("""C:\Pro gram Files\Microsoft
                  Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() &
                  "\Sunday.ppt""" )
                  Case 2
                  Shell("""C:\Pro gram Files\Microsoft
                  Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() &
                  "\Monday.ppt""" )
                  Case 3
                  Shell("""C:\Pro gram Files\Microsoft
                  Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() &
                  "\Tuesday.ppt"" ")
                  Case 4
                  Shell("""C:\Pro gram Files\Microsoft
                  Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() &
                  "\Wednesday.ppt """)
                  Case 5
                  Shell("""C:\Pro gram Files\Microsoft
                  Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() &
                  "\Thursday.ppt" "")
                  Case 6
                  Shell("""C:\Pro gram Files\Microsoft
                  Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() &
                  "\Friday.ppt""" )
                  Case 7
                  Shell("""C:\Pro gram Files\Microsoft
                  Office\OFFICE11 \powerpnt.exe"" /s " & Chr(34) + CurDir() &
                  "\Saturday.ppt" "")
                  End Select
                  Catch e As SecurityExcepti on
                  MsgBox(e.Messag e)
                  End Try
                  End
                  End Sub
                  >
                  Thanks for any advise!
                  George Atkins
                  >


                  Comment

                  Working...