+ Reply to Thread
Results 1 to 2 of 2

Converting DOS Commands to VBA function

  1. #1
    Forum Contributor
    Join Date
    03-07-2006
    Location
    India
    MS-Off Ver
    MSOffice 365 Professional 64 bit
    Posts
    108

    Converting DOS Commands to VBA function

    I have the below batch file that remaps an existing Y: drive remote shared folder to another freely available drive letter, and then disconnects Y: drive and remaps it to my chosen remote folder or local folder.

    But i don't know how to convert this batch code into a VBA function i.e. similar to below shown function. I am mainly having problems with the double-quotes in `sCMD` string.

    Any help would be most appreciated.

    What the batch commands do is :
    See if the concerned Drive e.g. Y: is available or not.
    If in use, assign Y:'s network path to the next freely available drive.
    Disconnect (delete) Y:
    Assign Y: to concerned Directory (Local or Remote).

    So need the `sCMD` properly double-quoted inorder to make it work!

    Please Login or Register  to view this content.
    Here is the function:
    Please Login or Register  to view this content.
    And here is the actual Batch code i wrote which works. Please note there is no error handling code to handle if all free drives are exhausted. If someone can also help with that, that would be useful for everyone :
    Please Login or Register  to view this content.

    http://www.vbaexpress.com/forum/show...o-VBA-Function
    Last edited by junoon; 03-06-2020 at 02:04 AM.

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Converting DOS Commands to VBA function

    Hi junoon,

    My speculation is that your problem is not sCmd, but is probably FullDirectory when it has embedded spaces. I've been successful by putting 4 double quotes before and after the variable name. For example:
    Please Login or Register  to view this content.
    See the file attached to post #4 in the following thread for a working example: http://www.excelforum.com/excel-prog...reposting.html

    Lewis

+ 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. [SOLVED] Converting Normal Excel function to DAX function
    By Vikas_Gautam in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 07-13-2016, 06:53 PM
  2. Multiple IF function commands
    By ruthyeh in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-21-2013, 11:19 AM
  3. Macro Recording Chart Format commands missing all important commands!!!!
    By nounours in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-05-2013, 09:20 PM
  4. Refreshing Array Commands for Sampling Without Replacement Function
    By gerrardfo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-04-2013, 03:38 PM
  5. Undo function to undo Visual Basic commands
    By pierre08 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-15-2010, 04:59 AM
  6. Sleep function between commands
    By rishadjb in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-01-2009, 09:31 PM
  7. Assign commands to function keys
    By Gerry in forum Excel General
    Replies: 4
    Last Post: 08-08-2005, 01: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