Re : Aide pour traitement d'une chaine de caractères (URL)
Merci beaucoup, le résultat est bien ce que je veux parcontre je souhaite intégré ce que tu as fait dans ma amcro que voici mais je n'y arrive pas
Sub OpenFiche()
Dim IE As InternetExplorer
Dim strFullName As String, strName As String, strOID As String, strOID_DOM As String, strtmp As String
Dim iposOID As Integer, iposOID_DOM As Integer, ipos As Integer
Dim strSite As String
Dim strAppName As String
Dim n As Integer
On Error GoTo endall
strAppName = Application.Name
If InStr(1, strAppName, "Excel") <> 0 Then
strName = ActiveWorkbook.Name
End If
On Error GoTo 0
strFullName = ActiveWorkbook.FullName
strtmp = Replace(strFullName, strName, "")
'Vérifions que le classeur est un classeur sur PC INFO
ipos = InStrRev(strtmp, "pcinfo.inetpsa.com")
If ipos > 0 Then
strSite = Mid(strtmp, 1, ipos + 17)
On Error Resume Next
'ouverture de IE
Set IE = GetObject(, "InternetExplorer")
If Err.Number <> 0 Then
Set IE = New InternetExplorer
Err.Clear
End If
On Error GoTo erreur
'http://dcpi.pcinfo.inetpsa.com/nav/document/fiche.do?OID=124727687
'http://dsc.pcinfo.inetpsa.com/doc/126103104.pc1fd
'-----------------------maj pcinfo--------------------
' N 17/10/06 Prend en compte les url du type pc1fx
'http://dsc.pcinfo.inetpsa.com/doc/126103104.pc1fd
'http://dsc.pcinfo.inetpsa.com/doc/126103104.pc1fm
'http://dsc.pcinfo.inetpsa.com/nav/document/fiche.do?OID=126103104.pc1fm
'http://dsc.pcinfo.inetpsa.com/nav/document/fiche.do?OID=126103104
If InStr(strFullName, "pc1fm") > 0 Then
'strFullName = Replace(strFullName, "/doc/", "/nav/document/fiche.do?OID=")
strFullName = Replace(strFullName, ".pc1fm", ".pc1fd")
IE.Navigate (strFullName)
While IE.Busy
Sleep 300
Wend
IE.Visible = True
Set IE = Nothing
Exit Sub
ElseIf InStr(strFullName, "viewFile.do") > 0 Then
strFullName = Replace(strFullName, "viewFile", "fiche")
IE.Navigate (strFullName)
While IE.Busy
Sleep 300
Wend
IE.Visible = True
Set IE = Nothing
Exit Sub
' Intergration dt ton code ici
Else
'-----------------------maj pcinfo--------------------
IE.Navigate (strtmp)
While IE.Busy
' 'Attendre
Sleep 500
Wend
IE.Visible = True
strtmp = IE.LocationURL
If InStr(1, strtmp, "OID_DOM=") < 1 Then
Sleep 1000
strtmp = IE.LocationURL
End If
If InStr(1, strtmp, "OID_DOM=") < 1 Then
IE.Quit
MsgBox "Vous n'êtes pas sous PCINFO DIFA."
GoTo erreur
End If
On Error GoTo 0
'définition des regles pour chemin d'acces
iposOID = InStr(1, strtmp, "OID=")
iposOID_DOM = InStr(1, strtmp, "&OID_DOM=")
strOID = Mid(strtmp, iposOID + 4, (Len(strtmp) - iposOID_DOM) - 8)
strOID_DOM = Mid(strtmp, iposOID_DOM + 9, Len(strtmp))
'accede à la fiche descritive
IE.Navigate (strSite & "/jsp/nav/document/pc1_index.jsp?OID=" & strOID & "&OID_DOM=" & _
strOID_DOM)
While IE.Busy
' 'Attendre
Sleep 300
Wend
IE.Visible = True
Set IE = Nothing
Exit Sub
End If
Else
MsgBox "Le classeur n'est pas sur PC Info. Vous ne pouvez pas consulter la fiche. " & Chr(10) & Chr(10) & " " & Chr(10) & " Contact : Nicolas ", , "Macro fiche Excel"
Exit Sub
End If
erreur:
Application.Workbooks.Open strFullName
endall:
End Sub