• Filecopy (Outlook 98, Excel 97)

    Author
    Topic
    #361112

    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.

    Viewing 2 reply threads
    Author
    Replies
    • #545205

      Looks like a typo on this line:

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

      … a space in front of .xls

      • #545206

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

    • #545346

      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?

      shrug 2cents

    • #545347

      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.

      • #545358

        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?

        hmmn 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”.

        brickwall

    Viewing 2 reply threads
    Reply To: Filecopy (Outlook 98, Excel 97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: