+ Reply to Thread
Results 1 to 7 of 7

"OpenFile" Code Cleanup

  1. #1
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    "OpenFile" Code Cleanup

    Hi all,
    I am currently tweeking my VBA for work. In one macro, I've prompted the user to enter the name of the file to open. I've then passed the name into a function that opens it if it is there or display an error message if it is not. I works just fine but I was hoping that a VB pro could tell me if I've done it right. Here is the Function:

    Please Login or Register  to view this content.
    Once this is passed and returned to my other macros, I have this:
    Please Login or Register  to view this content.
    Is this okay?
    Any insight will be truly appreciated.

    Regards:
    Last edited by Mordred; 09-23-2010 at 12:29 PM.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: "OpenFile" Code Cleanup

    Maybe like this:

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: "OpenFile" Code Cleanup

    A minor point: you have a double "the" in your msgbox message.

    "Please rerun the the update and enter the proper filename"

  4. #4
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: "OpenFile" Code Cleanup

    Haha, thanks for point out the 'the the'. I'll take care of it.

  5. #5
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: "OpenFile" Code Cleanup

    Wouldn't this be simpler and replace the whole function ?

    Please Login or Register  to view this content.



  6. #6
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: "OpenFile" Code Cleanup

    Quote Originally Posted by snb View Post
    Wouldn't this be simpler and replace the whole function ?

    Please Login or Register  to view this content.
    This goes straight to Exit Sub, even thought the file is there.

  7. #7
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: "OpenFile" Code Cleanup

    I don't think so.

+ 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