Consulting

Results 1 to 8 of 8

Thread: Solved: Open Ms On Screen Keyboard

  1. #1
    VBAX Regular
    Joined
    Mar 2010
    Posts
    49
    Location

    Solved: Open Ms On Screen Keyboard

    I would like to know if it's possible to open the MS On screen keyboard via a VBA code.I have tried this bus it does not work:Sub OnScreenkeyboard() On Error Resume Next AppVal = Shell("%windir%\system32\osk.exe", 1)If Err 0 Then MsgBox "Can't start the application.", vbCritical, "Error" End IfEnd SubMany thanks

  2. #2
    VBAX Expert
    Joined
    Aug 2007
    Location
    Windermere, FL, a 'burb in the greater Orlando metro area.
    Posts
    567
    Location
    Softman,

    Your code will be easier to read if you click the VBA button above the message entry box before you paste your code in into your message. This will generate the tags: [vba][/vba], then put your cursor between then and insert your code. It should come out looking like this:
    [vba]Sub OnScreenkeyboard()
    On Error Resume Next
    AppVal = Shell("%windir%\system32\osk.exe", 1)
    If Err 0 Then ' << there is an vba error here, do you need an = sign between Err and 0?
    MsgBox "Can't start the application.", vbCritical, "Error"
    End If
    End Sub
    [/vba]

    Cheers,
    Ron
    Windermere, FL

  3. #3
    VBAX Mentor
    Joined
    Aug 2008
    Posts
    323
    Location
    [VBA]
    Sub OnScreenkeyboard()
    Dim Apath As String
    Apath = "C:\Windows\system32\osk.exe"
    FollowHyperlink Apath
    End Sub
    [/VBA]

    I am not sure why the shell function isnt working , but this a workaround
    I am a Newbie, soon to be a Guru

  4. #4
    VBAX Regular
    Joined
    Mar 2010
    Posts
    49
    Location
    nepotist, I am still getting error "can not open specified fiel"

    For some reason my VBA did not work, sorry

  5. #5
    VBAX Mentor
    Joined
    Aug 2008
    Posts
    323
    Location
    What is the error?

    Recheck the path for your windows directory..It worked for me or repost you code
    I am a Newbie, soon to be a Guru

  6. #6
    VBAX Regular
    Joined
    Mar 2010
    Posts
    49
    Location
    can not open specified file - I will try this tonight on another machine

  7. #7
    VBAX Tutor
    Joined
    Sep 2007
    Posts
    265
    Location
    Hi guys

    This is from Simon code
    [VBA]Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, _
    ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    Sub Launch_It()
    ShellExecute 0, vbNullString, "osk.exe", vbNullString, "C:\", 1
    End Sub
    [/VBA]

    hope this help

  8. #8
    VBAX Regular
    Joined
    Mar 2010
    Posts
    49
    Location
    Works like a bomb! Many thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •