+ Reply to Thread
Results 1 to 3 of 3

Issues converting VBA to VBS - Using ShellAndWait with APIs

  1. #1
    Registered User
    Join Date
    07-26-2011
    Location
    Richmond, Virginia
    MS-Off Ver
    Excel 2007
    Posts
    10

    Issues converting VBA to VBS - Using ShellAndWait with APIs

    Hello scripters, I'm having some issues converting some VBA code to run in VB script format and i could use some help please.

    I have the following VBA code that runs in a module and works perfectly. The code loops a WSH shell call to a executable, then waits for the exe to complete before moving to the next iteration. I don't necessarily need this code to be modified. I am running into issues trying to get code ported to run in VBS format. I've been doing some research on various components of VBA that dont exist in VBS, but i dont that applies here. Thanks for looking. The first three snippets all run from a VBA module, and the in progress stuff is just that. I basically copied the VBA to a new file and started to strip out and reformat syntax, to the best of my ability. I'm also assuming i'll need/use the APIs in the same way as before...this is foggy to me

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    ########The VBS starts here########
    Please Login or Register  to view this content.

    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    07-26-2011
    Location
    Richmond, Virginia
    MS-Off Ver
    Excel 2007
    Posts
    10

    Talking Re: Issues converting VBA to VBS - Using ShellAndWait with APIs

    I had to do away with the API calls, so now two VBA routines becomes one VBS. Using .Run, I now can at least execute a shell call to my prog and wait. Can someone confirm, setting bWaitOnReturn will prevent a subsequent shell call from occurring until the previous finishes? That is how I understand it to work, but I still get an occassional crash. I'm looking into anything that would ensure smooth and graceful termination of the main program between loop iterations. Sub RunProgs is called numerous times by another routine.

    Please Login or Register  to view this content.

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Issues converting VBA to VBS - Using ShellAndWait with APIs

    Hello wherbjr35,

    Setting the argument bWaitOnReturn to True will halt the script execution until the program finishes, and Run returns any error code returned by the program. This only applies to the code you have called. If the VBS is being called by others then each module runs independently. You should check the return value from the run method before proceeding in your loop. If a program has failed to execute then you probably should alert the user and stop the procedure until the error has been corrected. Continuing on may be the cause of the crash.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Formatting issues with converting .xls to .csv
    By stephensgroup in forum Excel General
    Replies: 5
    Last Post: 03-09-2012, 01:22 PM
  2. Beginner help with APIs
    By guss in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-29-2010, 06:40 PM
  3. Issues converting a race points lookup table
    By 450nick in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-10-2009, 12:09 PM
  4. [SOLVED] List of superseded APIs
    By Paul Martin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-01-2006, 02:30 AM
  5. Where's the Documentation for the APIs?
    By Peter in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-04-2005, 02:05 PM

Tags for this Thread

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