Results 1 to 11 of 11
  1. #1
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Houston, Texas, USA
    Posts
    432
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem start Excel from Outlook form (Outlook 98, Excel 97)

    Whenever I call up Excel from a Users PC and Excel (Office) is on the C: drive it works fine. But if the user has their Excel (Office) on the D: drive it will just pause for about 10 seconds and then continue with the next functions with out performing the Excel function. This is a sample on how I call it up.

    '-=-=-=-=-=-=-=-=-=-
    'Call Excel
    Sub cmdExcel_click()
    Set objWSHShell = CreateObject("WScript.Shell")
    objWSHShell.Run("excel.exe securityMasterTerm.xls")
    end sub
    '-=-=-=-=-=-=-=-=-=-=-=-=-

    I need to fix this ASAP.

  2. #2
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem start Excel from Outlook form (Outlook 98, Excel 97)

    Just a thought (or two): are you saying that when Excel is on the D: drive Outlook is also on the D: drive - or is it always on the C: drive? Have you tried using RegRead to pass the AppPath for Excel?

    HTH
    Gre

  3. #3
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Houston, Texas, USA
    Posts
    432
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem start Excel from Outlook form (Outlook 98, Excel 97)

    Didn't load the software so I'm not sure where everthing is. The only thing I checked was to see where Excel was. In my code I assume that it is on the C: drive (90% of the machines are set up that way).

    I have not tried Regread to pass the AppPath. Not sure where to find this or how to use it. Will look into it today. Thank you

  4. #4
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem start Excel from Outlook form (Outlook 98, Excel 97)

    RegRead delivers you any value in the Registry. AppPath gives you the fully qualified path in the Registry where applications have been installed. There are examples of code calling these functions through the MS Scripting function on the Lounge. Sorry a bit pressed for time.

    HTH
    Gre

  5. #5
    5 Star Lounger
    Join Date
    May 2001
    Location
    Washington, USA
    Posts
    750
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem start Excel from Outlook form (Outlook 98, Excel 97)

    I think you need to have a reference to to target program in the project library. I don't know where you find it in Outlook 98. But it might be worth a look-see.

  6. #6
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Houston, Texas, USA
    Posts
    432
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem start Excel from Outlook form (Outlook 98, Excel 97)

    The first part is what I use from Outlook to start Excel and the process....
    -=-=-=-=-=-=-=-=-=-
    'Call Excel
    Sub cmdExcel_click()
    Set objWSHShell = CreateObject("WScript.Shell")
    objWSHShell.Run("excel.exe securityMasterTerm2.xls")
    end sub
    '-=-=-=-=-=-=-=-=-=-=-=-=-

    In the Excel spreadsheet I have the following macro (vb) in excel

  7. #7
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem start Excel from Outlook form (Outlook 98, Excel 97)

    You are using the Windows Scripting Model and the "Run" property to open Excel. "RegRead" is another Property. I regret I cannot duplicate exactly your environment, but the following script obtains the path to Excel from the Registry and uses it to open a nominated file. If the issue is that the current form of the script assumes Excel is on the C: drive, this may solve it by telling the Shell to look on whichever drive that Excel is installed on.

    Dim bKey
    Set objWSHShell = CreateObject("WScript.Shell")
    bKey=objWSHShell.RegRead("HKLMSoftwareMicrosoftWin dowsCurrentVersionApp PathsExcel.exe")
    bKey=bKey&" c:homebackupsketchpad.xls"
    objWSHShell.Run(bKey)

    HTH
    Gre

  8. #8
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Houston, Texas, USA
    Posts
    432
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem start Excel from Outlook form (Outlook 98, Excel 97)

    I tried this today and nothing happend.

    I added Msgbox"Excel = " & bkey just before the last line. It gave me the right path that Excel is in and the correct path to where I have the spreadsheet located.

  9. #9
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem start Excel from Outlook form (Outlook 98, Excel 97)

    Hi Daniel

    The idea I was putting across was that you substituted the 5 lines I posted for the 2 lines of code in your existing Sub - so it would read:

    Sub cmdExcel_click()
    Dim bKey
    Set objWSHShell = CreateObject("WScript.Shell")
    bKey=objWSHShell.RegRead("HKLMSoftwareMicrosoftWin dowsCurrentVersionApp PathsExcel.exe")
    bKey=bKey&" c:homebackupsketchpad.xls"
    objWSHShell.Run(bKey)
    end sub

    The problem you seemed to be having was that your previous code (by saying just "excel.exe" somehow defaulted to believing that Excel was installed on C: What this code does is call Excel from wherever it is specifically installed - C: D: whatever. "MsgBox" tells us that the code does actually work on your machines. If you use "objWSHShell.Run", we should get the file opening as desired on all of your machines.

    HTH
    Gre

  10. #10
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Houston, Texas, USA
    Posts
    432
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem start Excel from Outlook form (Outlook 98, Excel 97)

    I did change my srctip to read:
    im bKey
    Set objWSHShell = CreateObject("WScript.Shell")
    bKey=objWSHShell.RegRead("HKLMSoftwareMicrosoftWin dowsCurrentVersionApp PathsExcel.exe")
    bKey=bKey&" c:documentstext.xls"
    'Msgbox"Excel = " & bkey
    objWSHShell.Run(bKey)

    When I look a the Msgbox it shows the right path to Excel and to the spreadsheet. Run I run this is goes into debug in VB at "objWSHShell.Run(bKey) and doesn't show any error or any thing.

  11. #11
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem start Excel from Outlook form (Outlook 98, Excel 97)

    The problem seems to be that the AppPath has a space in it. On the basis that the machines have default installations, try:

    Dim bKey
    Set objWSHShell = CreateObject("WScript.Shell")
    bKey=objWSHShell.RegRead("HKLMSoftwareMicrosoftWin dowsCurrentVersionApp PathsExcel.exe")
    bKey=Left(bKey, 3)
    bKey=bKey&"Progra~1Micros~1OfficeExcel.exe c:documentstext.xls"
    'Msgbox"Excel = " & bkey
    objWSHShell.Run(bKey)

    The "bKey=Left(bKey, 3)" extracts the drive on which Excel is installed: C: or D:. Tailor the rest of the code to your set-up.

    HTH
    Gre

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •