Re: Best way to determine installed version of MS Office



Thank you, Mike. I did re-post in a better forum. And I'll look into your
suggestions, too. Appreciate the good tips. Have a nice day!
George

"MikeD" wrote:


"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

  • Re: Reading IE browser contents?
    ... The Document object represents the loaded page. ... "Microsoft Shell Controls and Automation" ... Dim ie2 As InternetExplorer ... windows AND IE windows. ...
    (microsoft.public.vb.general.discussion)
  • Re: laptop is suddenly running very slowly
    ... >Install and run AdAware and Spybot Search and Destroy. ... commercial malware's slowdown effect is rarely extreme without being ... The fact that refreshing the desktop is slow, ... intrusions or garbage in the shell. ...
    (microsoft.public.windowsxp.general)
  • Re: Running Excel
    ... I've gotten away from the SHELL command and am stuck with what appears to be ... Private Sub Command32_Click ... Dim xlWorkbook As Excel.Workbook ... > When you use Shell, you lose all subsequent control of the shelled program. ...
    (microsoft.public.access.modulesdaovba)
  • Re: FreeBSD5.4 - GUI fails
    ... I don't believe you're intended to install *everything* on the CDs. ... > ii.) FreeBSD boots with login prompt: only in shell mode,no GUI at ... For xdm and similar login managers, you need a .xsession script. ... > configuration is required, after enabling GNOME, ...
    (freebsd-questions)
  • Adding a custom application to XP Embedded
    ... since i'm new to XP Embedded, i'll ask some general questions. ... As i understood it's necessary to install the application in the XP Pro ... shell, i'll have to add a component with the prototype set to "Shell ... application directly on the running XP Embedded system. ...
    (microsoft.public.windowsxp.embedded)

Loading