Results 1 to 5 of 5

Thread: opening word

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2000
    Posts
    9
    If i had a button that when the user clicked on it, microsoft word would open up, what is the code i would use to do this?

  2. #2
    Junior Member
    Join Date
    Feb 2000
    Location
    England
    Posts
    26
    You could also use the Shell Command if you know where the Word.exe file is

    Shell("C:\Prog Files\MS Office\Winword.exe"),vbNormalFocus ' Your Path to WORD


    Hutchie

  3. #3
    Lively Member
    Join Date
    Jun 1999
    Posts
    120
    you could also use
    AppActivate

    refer to VB Help...

  4. #4
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    You could use any of the following to have full code functionality control. Look up in the help! The example are good to start off.

    CreateObject
    GetObject
    DDE

    or

    HDR's posting

  5. #5
    Lively Member
    Join Date
    Jun 1999
    Location
    East Anglia, England
    Posts
    73
    Here is some code for you to try, to use this just add a command button to you form and paste the code in

    Code:
    Option Explicit
    
    Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias _
       "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, _
       ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) _
       As Long
    
    Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias _
       "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, _
       ByVal lpReserved As Long, lpType As Long, _
       ByVal lpData As String, lpcbData As Long) As Long
                   'Note that if you declare the lpData parameter as String,
                   'you must pass it ByVal.
                                                                                       
    Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
    
    Const REG_SZ As Long = 1
    Const KEY_ALL_ACCESS = &H3F
    Const HKEY_LOCAL_MACHINE = &H80000002
       
    Private Sub Command1_Click()
    Dim hKey As Long
    Dim RetVal As Long
    Dim sCLSID As String
    Dim sPath As String
    
    
       'First, get the clsid from the progid
       'from the registry key:
       'HKEY_LOCAL_MACHINE\Software\Classes\<PROGID>\CLSID
       RetVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\Classes\" & _
          "Word.Application" & "\CLSID", 0&, KEY_ALL_ACCESS, hKey)
       If RetVal = 0 Then
          Dim n As Long
          RetVal = RegQueryValueEx(hKey, "", 0&, REG_SZ, "", n)
          sCLSID = Space(n)
          RetVal = RegQueryValueEx(hKey, "", 0&, REG_SZ, sCLSID, n)
          sCLSID = Left(sCLSID, n - 1)  'drop null-terminator
          RegCloseKey hKey
       End If
       
       'Now that we have the CLSID, locate the server path at
       'HKEY_LOCAL_MACHINE\Software\Classes\CLSID\
       '     {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx}\LocalServer32
        RetVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _
            "Software\Classes\CLSID\" & sCLSID & "\LocalServer32", 0&, _
          KEY_ALL_ACCESS, hKey)
       If RetVal = 0 Then
          RetVal = RegQueryValueEx(hKey, "", 0&, REG_SZ, "", n)
          sPath = Space(n)
          RetVal = RegQueryValueEx(hKey, "", 0&, REG_SZ, sPath, n)
          sPath = Left(sPath, n - 1)
          Shell sPath, vbNormalFocus
          RegCloseKey hKey
       End If
    End Sub

Posting Permissions

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



Click Here to Expand Forum to Full Width