Closed Thread
Results 1 to 5 of 5

transfer the commands to command promt

Hybrid View

  1. #1
    Registered User
    Join Date
    02-20-2014
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    2

    transfer the commands to command promt

    Hello,
    I need to transfer two commands to command prompt. The first one is always the same and it calls a command line of another application (BEAM).
    The second command is for the BEAM command line. It is taken from an Excel cell.
    The code I managed to write is transfering only the first command, probably because after execution of the first command command prompt is getting BEAM command line.
    I don't know what to do...

    Public Clipboard As New MSForms.DataObject
    Sub Mymacro()
        Dim DataObj As New MSForms.DataObject
        Dim strContents As String
        Dim strCmd As String
        Dim RetVal, A, fs
            
        Range("A1").Copy
        
        DataObj.GetFromClipboard
        strContents = DataObj.GetText
        strCmd = "cmd.exe /S /K C:\temp\beam-cli.bat"
        
        Set fs = CreateObject("Scripting.FileSystemObject")
        Set A = fs.CreateTextFile("C:\temp\vb.bat", True)
        A.writeline strCmd
        A.writeline strContents
        A.Close
    
        RetVal = Shell("C:\temp\vb.bat", 1)
    
    End Sub
    Last edited by alansidman; 02-20-2014 at 09:27 PM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,698

    Re: transfer the commands to command promt

    Code Tags Added
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html



    (Because you are new to the forum, I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    02-20-2014
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: transfer the commands to command promt

    Okaaaay, fixed the problem using SendKeys...

  4. #4
    Registered User
    Join Date
    03-14-2015
    Location
    India
    MS-Off Ver
    2007
    Posts
    2

    Re: transfer the commands to command promt

    Hi Feba,

    I also want to run a set of commands in command prompt through VBA. Could you please help me how to do that with SendKeys???

    Thanks in Advance.

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,698

    Re: transfer the commands to command promt

    A N Rahman

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Open one command window and execute a series of commands from it.
    By Air_Cooled_Nut in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-03-2014, 11:48 AM
  2. [SOLVED] Command button to transfer between shhets
    By troysie in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-21-2013, 02:53 AM
  3. VBA to command prompt - sending multiple commands to same line?
    By JP Romano in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-07-2012, 10:42 AM
  4. Macro for command button to transfer value
    By Strugggler in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-26-2009, 06:27 PM
  5. running unix commands using vba "shell" command on mac OS X
    By fakeleft in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-09-2005, 06:08 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