+ Reply to Thread
Results 1 to 8 of 8

Coding Cmd Button in userform

Hybrid View

Karkas Coding Cmd Button in userform 04-03-2009, 05:00 PM
Kenneth Hobson Re: Help Coding Cmd Button in... 04-03-2009, 05:22 PM
Karkas Re: Help Coding Cmd Button in... 04-03-2009, 05:41 PM
Karkas Re: Help Coding Cmd Button in... 04-03-2009, 05:55 PM
Kenneth Hobson Re: Help Coding Cmd Button in... 04-03-2009, 06:40 PM
Karkas Re: Help Coding Cmd Button in... 04-03-2009, 08:23 PM
JBeaucaire Re: Help Coding Cmd Button in... 04-03-2009, 08:17 PM
Karkas Re: Help Coding Cmd Button in... 04-03-2009, 08:20 PM
  1. #1
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Help Coding Cmd Button in userform

    Welcome to the Forum!

    Private Sub CommandButton1_Click()
      Worksheets("Sheet2").Range("A1").Value = TextBox1.Value
      'etc. for others
      Shell "cmd /c winword " & """" & "X:\MSWord\test.doc" & """", vbNormalFocus
      Unload Me
    End Sub

  2. #2
    Registered User
    Join Date
    04-03-2009
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    15

    Re: Help Coding Cmd Button in userform

    I did a quick trial and while I didn't get any errors nothing seemed to happen.

    This is what I have.

    Private Sub CommandButton1_Click()
      Worksheets("Sheet3").Range("B2").Value = lstName.Value
      'etc. for others
      Shell "cmd /c winword " & """" & "C:\test.txt" & """", vbNormalFocus
      Unload Me
    End Sub
    
    Private Sub CmdOrder_Click()
    
    End Sub
    What did I enter wrong?

    Thanks for the help BTW!

  3. #3
    Registered User
    Join Date
    04-03-2009
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    15

    Re: Help Coding Cmd Button in userform

    OK, I reentered it as

    Private Sub CmdOrder_Click()
    Worksheets("Patient").Range("B2").Value = lstName.Value
      'etc. for others
      Shell "cmd /c winword " & """" & "C:\test.txt" & """", vbNormalFocus
      Unload Me
    End Sub
    It works! Thanks a million!

    However, I notice the cmd window pops up, is there a way to kill it after it launches the document?

  4. #4
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Help Coding Cmd Button in userform

    You can hide it.
    Shell "cmd /c winword " & """" & "x:\MSWord\Test.doc" & """", vbHide

  5. #5
    Registered User
    Join Date
    04-03-2009
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    15

    Re: Help Coding Cmd Button in userform

    Quote Originally Posted by Kenneth Hobson View Post
    You can hide it.
    Shell "cmd /c winword " & """" & "x:\MSWord\Test.doc" & """", vbHide
    BTW, thank you so much! It is working perfectly now!

+ 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