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

    Filecopy (Outlook 98, Excel 97)

    I have an Outlook for with VB copy in it. I am trying to copy file 1 to file 2. THe files are located on a network drive. This was working until I added the Filecopy line.

    Call Excel
    Sub cmdExcel_click()
    Filecopy "tabsproddatabaseedgarsecuritymastertest.xls", "tabsproddatabaseedgarsecuritytest.xls"
    Set objWSHShell = CreateObject("WScript.Shell")
    objWSHShell.Run("excel.exe tabsproddatabaseedgarsecurityTEST.xls ")
    end sub

    It is giving me a Type Mismatch. Can anyone tell me what I am doing wrong.

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Filecopy (Outlook 98, Excel 97)

    Looks like a typo on this line:

    objWSHShell.Run("excel.exe tabsproddatabaseedgarsecurityTEST.xls ")

    ... a space in front of .xls
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

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

    Re: Filecopy (Outlook 98, Excel 97)

    Just checked the code out. No space, just looks that way.

  4. #4
    2 Star Lounger
    Join Date
    Feb 2001
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Filecopy (Outlook 98, Excel 97)

    Two things that I can think of.

    1) Shouldn't the shell command string look like "start tabsproddatabaseedgarsecurityTEST.xls "

    Shell is essentially running something from the DOS prompt. If you can get it to run from the DOS prompt, it usually works in Shell. I've had problems with putting excel.exe since my system requires the full path to excel.exe. If you use the START command followed by a filename. It will launch the application that is associated with the extension of the filename.

    2)I don't think you need to use the WScript.Shell object. Shouldn't VB's SHELL command do the same thing saving you from creating an object?

    <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15> <img src=/S/2cents.gif border=0 alt=2cents width=15 height=15>

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

    Re: Filecopy (Outlook 98, Excel 97)

    The problem I am having has to do with the FIlecopy command. If I take this line out or comment it the rest work fine. I want to copy mastertest.xls file to the test.xls file.

  6. #6
    2 Star Lounger
    Join Date
    Feb 2001
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Filecopy (Outlook 98, Excel 97)

    I understand your problem. How many times have we gotten an error or a warning in a program when it turns out to be something other than the line of code that spouts the error or warning?

    <img src=/S/hmmn.gif border=0 alt=hmmn width=15 height=15> Wait a minute! This is Outlook 98, right? If I'm correct, Outlook 98 uses VBScript not VBA/VB. That means that the FileCopy statement doesn't exist since it's a VBA/VB statement not a VBScript statement. You'll probably need to use the FileSystemObject's copyfile method.

    You won't be able to use VB's SHELL statement in my previous post. I still think using "start" in the shell command string will work better than just "excel.exe".

    <img src=/S/brickwall.gif border=0 alt=brickwall width=25 height=15>

Posting Permissions

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