Re: Best way to determine installed version of MS Office




"GeorgeAtkins" <GeorgeAtkins@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:3ABFC995-8926-4A6A-A949-CFD1A0F44257@xxxxxxxxxxxxxxxx
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 (hardcoded path). I now want to have the program run the Shell
for either Office 11 or Office 12, depending upon which version is
installed
on a desktop. What is the most efficient way to code this?

My code is as follows:
Sub main()
Try
Dim ps1 As New PermissionSet(PermissionState.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:\Program Files\Microsoft
Office\OFFICE11\powerpnt.exe"" /s " & Chr(34) + CurDir() &
"\Sunday.ppt""")
Case 2
Shell("""C:\Program Files\Microsoft
Office\OFFICE11\powerpnt.exe"" /s " & Chr(34) + CurDir() &
"\Monday.ppt""")
Case 3
Shell("""C:\Program Files\Microsoft
Office\OFFICE11\powerpnt.exe"" /s " & Chr(34) + CurDir() &
"\Tuesday.ppt""")
Case 4
Shell("""C:\Program Files\Microsoft
Office\OFFICE11\powerpnt.exe"" /s " & Chr(34) + CurDir() &
"\Wednesday.ppt""")
Case 5
Shell("""C:\Program Files\Microsoft
Office\OFFICE11\powerpnt.exe"" /s " & Chr(34) + CurDir() &
"\Thursday.ppt""")
Case 6
Shell("""C:\Program Files\Microsoft
Office\OFFICE11\powerpnt.exe"" /s " & Chr(34) + CurDir() &
"\Friday.ppt""")
Case 7
Shell("""C:\Program Files\Microsoft
Office\OFFICE11\powerpnt.exe"" /s " & Chr(34) + CurDir() &
"\Saturday.ppt""")
End Select
Catch e As SecurityException
MsgBox(e.Message)
End Try
End
End Sub


Don't use Shell and NEVER hard-code paths. If a user doesn't install Office
(or PowerPoint) to the default installation folder, your code is never going
to work. Use Automation or the FindExectuable Win32API function (or I
suppose you could shell using the ShellExecute API function).

However, since your using VB.NET (the Try..Catch gives it away), you're
posting to the wrong newsgroup. This one's for VB6 and under. You want to
post to one with "dotnet" or "vsnet" in the name.


--
Mike
Microsoft MVP Visual Basic


.



Relevant Pages

  • Best way to determine installed version of MS Office
    ... I wrote a small Exe that simply runs Shell to load PowerPoint and launch a ... depending on the day of the week. ... I now want to have the program run the Shell ... ' Launch the powerpoint file for the current day of the week. ...
    (microsoft.public.vb.syntax)
  • Re: Launching PowerPoint from within Access
    ... assume that PowerPoint is resident on the target machine. ... Kind regards Paul ... The advantage of the latter 2 approaches over Shell is that Shell ...
    (microsoft.public.access.formscoding)
  • Re: Launching PowerPoint from within Access
    ... Do I need an Office 2000 PowerPoint Viewer, ... Doug Steele, Microsoft Access MVP ... Kind regards Paul ... The advantage of the latter 2 approaches over Shell is that Shell ...
    (microsoft.public.access.formscoding)
  • determining current version of PowerPoint
    ... office 2003 and I also used Shell. ... Powerpoint file, regardless of which version of Office is running? ... Dim DayOfWeek As Integer ... ' Launch the powerpoint file for the current day of the week. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Show Powerpoint with VB
    ... > done things like Shell and starting Word, used SQL for Access db's etc. ... You probably be better off asking in the PowerPoint group. ... Dim ppt As PowerPoint.Application ...
    (microsoft.public.vb.controls)