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 38 39 40 41 42
| Sub par()
Dim stfil As String
Dim t1, t2, t3, t4 As String
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
Dim objStream, strData
Dim arr() As String
Set objStream = CreateObject("ADODB.Stream")
objStream.Charset = "utf-8"
objStream.Open
objStream.Type = 1
objStream.LoadFromFile (FileName)
sBody = objStream.Read()
objStream.Close
Set objStream = Nothing
sharepointUrl = "https://sharepoint.com/ect..."
Dim sharepointFileName
arr() = Split(FileName, "\")
t1 = arr(UBound(arr))
t2 = Left(t1, InStr(1, t1, ".") - 1)
t3 = StrReverse(Left(StrReverse(t1), InStr(1, StrReverse(t1), ".")))
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
Feuil1.Hyperlinks.Add anchor:=Range("L24"), Address:=sharepointFileName
End If
End If
End Sub |
Partager