+ Reply to Thread
Results 1 to 8 of 8

Bug in Excel 2003 Application.Run with dashes in filenames

  1. #1
    Registered User
    Join Date
    11-25-2007
    Posts
    46

    Bug in Excel 2003 Application.Run with dashes in filenames

    I am using Excel 2003. The macro below opens a workbook "Book1.xls" and runs a simple macro "Opening" which in this case is just a simple message box for test purporses. This macro will fail if the workbook is named "Book-1.xls".

    I even tested with the workbook in subdirectories which had dashes in the folder name, and the macro works as long as the file name itself does not have a dash.

    Please Login or Register  to view this content.
    Code originally from VBA Express Portal

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Are you sure the pathtofile is correct
    "C:\Documents and Settings\user\Desktop"
    user is not a normal Windows login id


    Suggest add these changes to your code
    Please Login or Register  to view this content.
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  3. #3
    Registered User
    Join Date
    11-25-2007
    Posts
    46

    Bug in Applicaton.Run

    I removed the actual user ID to provide some anonymity with my post, the real one is normal.

    Any idea why Excel gags on "Book-1.xls" but okay with "Book1.xls". I think a dash is a legal Windows/Dos character?

  4. #4
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    I use Excel 2003 on Windows XP SP2

    Your code works for me even if their is a - in the file name (As long as I use my ID in place of user in the path)

    Have you tried opening a file saved to a different location than the desktop

  5. #5
    Registered User
    Join Date
    11-25-2007
    Posts
    46
    All my trials have been with the calling workbook on the desktop and workbooks to open in folders on the desktop. When I discovered the issue I created the workbook Book1.xls directly on the desktop to speed troubleshooting.

    I was planning on moving a folder to my desktop from a server, run the macro to open each file in the folder and do it's business. Then move the folder back to server. Seemed easiest to move to the desktop.

    I can give this a try.

  6. #6
    Registered User
    Join Date
    11-25-2007
    Posts
    46
    I did try in a normal folder in my computer. This time leaving in my WinID in the example. Still fails with the name containing a dash vs no dash. Also tested with an underscore Book_1.xls, and this works fine.

    I have been changing all my files to not have dashes as a work around.

    Please Login or Register  to view this content.
    Last edited by mudraker; 12-20-2007 at 01:03 AM.

  7. #7
    Registered User
    Join Date
    11-25-2007
    Posts
    46
    Sorry about the prior note, I did try to use the # but I must have deleted the all important bracket by mistake.

  8. #8
    Registered User
    Join Date
    11-25-2007
    Posts
    46

    Solution to bug with Application.Run

    I found out that modifying the application run statement putting the file name with the dash inside single quotes allows the macro to run correctly.

    Please Login or Register  to view this content.
    Cam

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1