Word Dokument öffnen

C

CK82

Kann mir jemand den Code geben um ein Word Dokument samt Word zu öffnen??

Vielen dank für die Hilfe

CK82
 
Option Explicit

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

Private Declare Function GetWindowsDirectory Lib "kernel32" _
Alias "GetWindowsDirectoryA" (ByVal lpBuffer As _
String, ByVal nSize As Long) As Long

Const SW_RESTORE As Long = &H9&

Private Sub Form_Load()
Dim Win$, Result&
Win = Space(256)
Result = GetWindowsDirectory(Win, Len(Win))
Text1.Text = Left$(Win, Result)
End Sub

Private Sub Command1_Click()
Call OpenExplorer(CStr(Text1.Text))
End Sub

Private Sub OpenExplorer(ByVal Path$)
Path = Left$(Path, Len(Path) - Len(Right$(Path, _
Len(Dir(Path)))))
Call ShellExecute(Me.hwnd, "explore", Path, 0, 0, SW_RESTORE)
End Sub


hoff damit gehts :)
 
in der vorletzten zeile sollte "explorer" durch
den pfad der datei ersetzt werden
zb:
Call ShellExecute(Me.hwnd, "C:\windows\word1.doc", Path, 0, 0, SW_RESTORE)

mfg
 
sollte auch anders gehen...

Dim oWordApp As Word.Application
Dim oWord As Word.Document

Set oWordApp = New Word.Application
Set oWord = oWordApp.Documents.add(strRet)
oWordApp.Visible = True
oWordApp.Activate

strRet ist hier der Pfad und Dateiname.

CU
Martin
 
Zurück