datei öffnen über VBA

OP #597061
Lesenswert?

Hallo zusammen.

hab mal wieder ein problem, diesmal mit VBA :(
möchte aus einem excel file in einem vba formular über einen button eine 
datei mit seinem standartprogramm öffnen. habe folgenden code im forum 
gfunden.

Problem:
es wird nur ein explorerfenster mit den angegebenen Pfad geöffnet 
anstatt der txt datei...
kann mir jemand helfen wiso?

code:

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 GetDesktopWindow Lib "user32" () As Long


Private Sub Cmdfeedback_Click()

filname = "open"

'Sub OpenFile(Filename As String)
Call ShellExecute(GetDesktopWindow(), "open", Filename, "", 
"P:\Teams\Prozesstechnik\3_Publikationen\02_Datenarchiv\01_Onlineaufzeic 
hnung",  1)




danke Gruss Raphael


Gast #597066
Lesenswert?

Ich mache immer folgendes:

Private Const SW_SHOWNORMAL = 1
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


...


ShellExecute Me.hWND, "open", "C:\test\test.xls", vbNullString, "C:\", 
SW_SHOWNORMAL



Aufruf erfolgt aus einem VB6 Formular heraus (das "Me"), ich denke 
GetDesktopWindow geht aber auch

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren