Results 1 to 12 of 12

Thread: command line

  1. #1
    New Lounger
    Join Date
    Jan 2001
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    command line

    I need to use a VB Shell command to launch Word with a specific document. (I would rather not launch it as an automation server. The application that launches it is a wizard which needs to shut down as soon as Word is launched.)

    Does anybody know if there is a command line argument for Word that will open a particular file?

    Thanks in advance.
    Joe Medley

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: command line

    The following worked for me from Excel VBA


    Shell "C:Program FilesMicrosoft Office2000OfficeWINWORD.EXE CocumentsWordTest.doc" - all one line and include quote marks


    Andrew C

  3. #3
    New Lounger
    Join Date
    Jan 2001
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: command line

    Thanks for the info. I still have one problem though. The command blows up if the document path contains any spaces. Did you run into this problem? If so, how did you get around it?

    Joe

  4. #4
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: command line

    Joe,

    I had not run into that particular problem because I never had that situation, but having now tried it, I have had the same experience as yourself.

    If I can find a solution I will let you know.

    Andrew.

  5. #5
    New Lounger
    Join Date
    Jan 2001
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: command line

    I'll do the same.

  6. #6
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: command line

    Hi Joe & Andrew:

    What happens if you replace the path with the DOS name, so that there are no spaces? Does it help?

  7. #7
    New Lounger
    Join Date
    Jan 2001
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: command line

    I hadn't thought of that. I imagine it should work.

    Since my path is a user entered value I need some way to convert. Will I have to write my own function for this or is there a command or API that will convert it?

  8. #8
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: command line

    Hi Joe:

    I haven't learned VBA, so I can't help you there. I just know that I've sometimes had the problem of Word rejecting a path with spaces, despite the fact that it was enclosed in quotes, so I've resorted to DOS names ocassionally. Perhaps you could post it on the VBA board.

  9. #9
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    GetDOSPath() (was Re: command line )

    Private Declare Function GetShortPathName Lib "kernel32" _
    Alias "GetShortPathNameA" (ByVal lpszLongPath As String, _
    ByVal lpszShortPath As String, _
    ByVal cchBuffer As Long) As Long

    -----
    Function GetDOSPath(strLongFileName As String, IsFolder As Boolean) As String
    'Uses Windows' GetShortPathName function to get a DOS-
    'compliant path or file name
    'Created 3/31/99 with help from Getz & Gilbert

    Dim strBuffer As String '8.3 file name/buffer
    Dim lngPathLen As Long 'length of path

    'preallocate space for return from Win32 API fxn
    strBuffer = Space(260)

    'call function
    lngPathLen = GetShortPathName(strLongFileName, _
    strBuffer, Len(strBuffer))

    ' If not a blank string then extract DOS path
    If lngPathLen > 0 Then
    GetDOSPath = Left(strBuffer, lngPathLen)
    'following added 5/2/99 just to be sure
    If IsFolder And (Right(GetDOSPath, 1) <> "") Then
    GetDOSPath = GetDOSPath & ""
    End If
    Else
    GetDOSPath = vbNullString
    End If
    End Function

  10. #10
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: command line

    Try this slightly different arrangement of the double quotes:

    <pre> Shell "C:Program FilesMicrosoft OfficeOfficeWINWORD.EXE ""C:FilesMy Document.doc"""
    </pre>

    Legare Coleman

  11. #11
    New Lounger
    Join Date
    Jan 2001
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: command line

    Actual I'm working in VB. It's the other guy who's working in VBA.

  12. #12
    New Lounger
    Join Date
    Jan 2001
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    GetDOSPath() (was Re: command line )

    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
  •