Bonjour à tous,
Je cherche à copier le texte d'un fichier dans une variable en vba toutefois cela ne fonctionne pas avec un fichier word. Voici mon code qui fonctionne bien pour un fichier .txt :
Merci d'avance pour votre aide,
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 Sub blabla () Dim XMLBody As String XMLBody = SelectionTxt("..donneePDF.doc") End sub Function SelectionTxt(SelectionFichier As String) Dim strFile As String Dim FreeCanal As Integer FreeCanal = FreeFile Dim Liste As String Dim nbMsg As Long Open SelectionFichier For Binary As #FreeCanal strFile = String$(LOF(FreeCanal), Chr$(0)) Get #FreeCanal, , strFile Close #FreeCanal SelectionTxt = strFile End Function
Ayoub.
Partager