Advertisement
ASP_Volume2 Files/ File Controls/ Input/ Output #29744

Launch file and associated program

How do I launch a file in its associated program? The Shell statement unfortunately only supports launching an EXE file directly. If you want to be able to launch, i.e. Microsoft Word by calling a .DOC file only, you can make your VB application launch the associated program with the document using the following method:

AI

Shrnutí AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Zdrojový kód
original-source
Function StartDoc(DocName As String) As Long
  Dim Scr_hDC As Long
  Scr_hDC = GetDesktopWindow()
  StartDoc = ShellExecute(Scr_hDC, "Open", DocName, "", "C:\", SW_SHOWNORMAL)
End Function
Private Sub Form_Click()
  Dim r As Long
  r = StartDoc("c:\my documents\word\myletter.doc")
  Debug.Print "Return code from Startdoc: "; r
End Sub
Upload
Původní komentáře (3)
Obnoveno z Wayback Machine