XL 2016 Ouvrir un fichier txt avec Notepad

epeter

XLDnaute Nouveau
Bonjour je souhaite ouvrir un fichier txt avec Notepad depuis une macro excel VBA. J'ai créé le code suivant mais quand je l'exécute il me mets un message comme quoi ma macro est malveillante. Comment solutionner le problème ?

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

Sub Tst()
Dim sFichier As String, WsShell As Object
sFichier = "C:\Users\manep\Downloads\PICT.txt"
Set WsShell = CreateObject("WScript.Shell")
WsShell.Run "NotePad " & sFichier
Set WsShell = Nothing
End Sub
 

Discussions similaires

Réponses
4
Affichages
420
Réponses
1
Affichages
1 K
Compte Supprimé 979
C

Membres actuellement en ligne

Statistiques des forums

Discussions
312 069
Messages
2 085 038
Membres
102 763
dernier inscrit
NICO26