Results 1 to 3 of 3
  1. #1
    Olszanski is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    2

    Open (shell) a program and pass a file

    Hi all,
    I am attempting to open a specific program and a specific file from Access. Basically, I've built a form which takes information. Once I've loaded new data into the form, I click a command button which opens Excel and passes the Access information to Excel and saves it. I then want to use a different program to do an analysis on this Excel data. In a similar fashion, I have a command button to open the program (called Spotfire) using the Shell command. However, when I try to pass my file, it opens SpotFire but then tells me that it can't find "C:\Documents". That is, it is not passing the whole file name. If I put a file in the "C:\" directory, it will open it just fine, but I'd like to keep my folder structure as is, without moving or renaming files. Is there a way to open my specified file? The code I have is:
    ___________________
    Private Sub Spotfire_App_Click() 'This opens SpotFire for analysis


    On Error GoTo Err_Spotfire_App_Click
    'The file I need to pass is: C:\Documents and Settings\AOlszans\My Documents\Medical Attending Information\Patient Log\Pt Log Analysis.dxp

    Dim stAppName As String ' this is the path for the program
    Dim strFile As String 'this is the path for the file

    stAppName = "C:\Program Files\TIBCO\Spotfire\3.0\Spotfire.Dxp.exe"
    strFile = "C:\Documents and Settings\AOlszans\My Documents\Medical Attending Information\Patient Log\Pt Log Analysis.dxp"

    'This is close but it can't find the appropriate strFile -- it is looking in "C:\" and not in any subroot directories

    Call Shell(stAppName & " " & strFile, vbMaximizedFocus)

    Exit_Spotfire_App_Click:
    Exit Sub
    Err_Spotfire_App_Click:
    MsgBox Err.Description
    Resume Exit_Spotfire_App_Click

    End Sub
    _______________________

    Any help is greatly appreciated.
    Tony

  2. #2
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    I don't know if this will work or not, but you can try including quotes around the file name using the Chr() Function.

    Code:
      Dim stAppName As String ' this is the path for the program
      Dim strFile As String 'this is the path for the file
     
      stAppName = "C:\Program Files\TIBCO\Spotfire\3.0\Spotfire.Dxp.exe"
      strFile = Chr(34) & "C:\Documents and Settings\AOlszans\My Documents\Medical Attending Information\Patient Log\Pt Log Analysis.dxp" & Chr(34)
     
      'This is close but it can't find the appropriate strFile -- it is looking in "C:\" and not in any subroot directories
     
      Call Shell(stAppName & " " & strFile, vbMaximizedFocus)
     
    Exit_Spotfire_App_Click:
       Exit Sub
    
    Err_Spotfire_App_Click:
       MsgBox Err.Description
      Resume Exit_Spotfire_App_Click
      End Sub
    If the above code doesn't work, you can always use the old 8.3 path/filename (or just make sure the path doesn't contain any spaces).

  3. #3
    Olszanski is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    2
    Thank you. This worked for me. I don't quite understand why though. I did try the short path (8.3 path) but for some reason Spotfire had troulbe opening the file that way. Thank you for your help!
    Tony

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Shell with Batch Variables
    By robbyaube in forum Programming
    Replies: 2
    Last Post: 12-19-2019, 11:06 AM
  2. Replies: 4
    Last Post: 05-20-2010, 03:49 AM
  3. Replies: 1
    Last Post: 08-19-2009, 01:54 AM
  4. Why 2 users cant open an access file directly???
    By finnegan bell in forum Access
    Replies: 6
    Last Post: 03-22-2009, 09:06 PM
  5. Can not open File already in use.
    By Wrangler in forum Access
    Replies: 1
    Last Post: 03-04-2009, 09:50 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums