0

So I'm trying to pass a string into the command line once I've opened it via shortcut (I had to open it up this way due to some permission issues and onedrive being weird. I understand the code for the most part, the problem I'm having is how to pass a string into command prompt once it's opened since I'm not doing it the traditional way, is there a method I can use to pass a string into this so command prompt can automate stuff I input?

Sub OpenFile()

  Dim FileName As Variant
  Dim FolderItem As Object
  Dim FolderPath As Variant
  Dim oFolder As Object
  Dim oShell As Object
 'Dim UserName As String

 'UserName = InputBox("ex", "ex", "ex")
  
    FolderPath = [B]"C:\Documents and Settings\users\Command Prmompt"[/B]
    FileName = [B]"Command Prompt.lnk"[/B]
    
      Set oShell = CreateObject("Shell.Application")
      Set FolderItem = oShell.Namespace(FolderPath).ParseName(FileName)
    
      FolderItem.Verbs.Item(0).DoIt
    
End Sub
Leafzer
  • 13
  • 3
  • Have you seen [Execute a command in command prompt using excel VBA](https://stackoverflow.com/questions/17956651/execute-a-command-in-command-prompt-using-excel-vba)? – Cyril Apr 07 '22 at 19:51
  • I have, but the issue with that is that calls cmd.exe from my onedrive. I need to specifically execute cmd the way I am here. FolderItem.Verbs.Item(0).DoIt is what is opening excel, I'm looking to see if there is another method I can add to that line that will pass a string once cmd is opened in this manner. – Leafzer Apr 07 '22 at 20:27

0 Answers0