1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| Sub par()
Dim stfil As String
Dim t2, t3, t4 As String
Dim p As Long
stfil = Application.GetOpenFilename
If stfil <> "Faux" Then
If MsgBox("êtes vous sûr de vouloir joindre ce fichier : " & stfil, vbYesNo, "vérification") = vbYes Then
Dim xmlhttp
Dim sharepointUrl
Dim FileName
Dim tsIn
Dim sBody
FileName = stfil
Dim ofc
Dim ofile
Set ofc = CreateObject("Scripting.FileSystemObject")
Set ofile = ofc.GetFile(FileName)
Set tsIn = ofile.OpenAsTextStream
sBody = tsIn.ReadAll
While Not tsIn.AtEndOfStream
MsgBox tsIn.ReadLine
Wend
MsgBox Len(sBody)
tsIn.Close
sharepointUrl = "https://sharepoint.com/ect..."
Dim sharepointFileName
t2 = Left(ofile.Name, InStr(1, ofile.Name, ".") - 1)
t3 = StrReverse(Left(StrReverse(ofile.Name), InStr(1, StrReverse(ofile.Name), ".")))
t4 = Format(Date, "yyyymmdd") & "_" & Format(Time, "hhmmss")
sharepointFileName = sharepointUrl & "/" & t2 & t4 & t3
Set xmlhttp = CreateObject("MSXML2.XMLHTTP.4.0")
xmlhttp.Open "PUT", sharepointFileName, False
xmlhttp.Send sBody
End If
End If
End Sub |
Partager