none
Command button to open a SharePoint file with spaces RRS feed

  • Question

  • Pulling my hair out over this one.  I have a command button on a form.  All it has to do it open an Excel file on SharePoint when clicked.  The problem is, the file name has spaces.  I have Googled a few things to try, but none work.  Before I ask the admin to remove the spaces from the filename, is there any way to open it with the spaces? This is a list of things I have tried, which all throw errors, usually “File Not Found”:

    1)  Call Shell("EXCEL.EXE https://FilePath/File Name.xlsx", vbNormalFocus)

    2)  Call Shell("EXCEL.EXE" & """https://FilePath/File Name.xlsx """, vbNormalFocus)

    3)  Call Shell("EXCEL.EXE" & Chr(34) & "https://FilePath/File Name.xlsx " & Chr(34), vbNormalFocus)

    4)

    Dim ShellStr As String

    ShellStr = """https:// FilePath/File Name.xlsx """

    Call Shell("EXCEL.EXE" & ShellStr, vbNormalFocus)


    Friday, April 27, 2018 2:43 PM

Answers

  • Never mind.  Figured it out.  I found the solution here:

    http://www.vbforums.com/showthread.php?607331-Open-excel-file-by-shell-function-under-a-click-event-of-a-command-button-in-VB6

    So, my final code is:

    Call Shell("""EXCEL.EXE"" ""https://FilePath/File Name.xlsx""", vbNormalFocus)

    • Marked as answer by TraciMarie Friday, April 27, 2018 6:14 PM
    Friday, April 27, 2018 6:14 PM