lionyz
Messages postés62Date d'inscriptionsamedi 10 janvier 2009StatutMembreDernière intervention30 octobre 2012
-
23 mars 2009 à 22:13
moscato40
Messages postés27Date d'inscriptionmardi 13 mai 2008StatutMembreDernière intervention24 juin 2010
-
23 avril 2009 à 17:41
Bonjour,
Quelqu'un peut il m'expliquer comment faire pour que les instructions
Senkeys "^(A)" -> Tout sélectionner et Senkeys "^(C)" -> copier
agisse sur une page web ouverte avec webbrowser1 et qui a le focus
avec WebBrowser1.SetFocus.
Merci de votre aide
A voir également:
"Url de la page, sur votre site, où est affiché le lien vers"
Private Sub Command1_Click()
Dim oDoc As HTMLDocument
Dim oMatch As Object
Dim oBody As Object
Set oDoc = WebBrowser1.document
If Not Nothing Is oDoc Then
Set oBody = oDoc.getElementsByTagName("body")
If oBody.length > 0 Then
Set oBody = oBody.Item(0)
For Each oMatch In .Execute(oBody.innerHTML)
MsgBox "Date: " & oMatch.SubMatches(0) & vbNewLine & _
"Nom: " & oMatch.SubMatches(1) & vbNewLine & _
"Division par: " & oMatch.SubMatches(2), vbInformation
Next oMatch
End With
End If
End If
End Sub
Private Sub Form_Load()
WebBrowser1.Navigate2 SOURCE_URL
End Sub
Private Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
Command1.Enabled = False
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Command1.Enabled (URL SOURCE_URL)
End Sub
lionyz
Messages postés62Date d'inscriptionsamedi 10 janvier 2009StatutMembreDernière intervention30 octobre 2012 24 mars 2009 à 11:38
Merci de ta réponse mais je sais peu de chose sur les interfaces COM
Ou puis je trouver les infos sur ce sujet ?
Je cherche à copier le texte d'une page web dans un fichier type bloc note
pour ensuite rechercher les infos dont j'ai besoin en analysant ce texte ligne par ligne.
Je ne sais pas comment rechercher directement ces infos sur la page web
Merci de ton aide
Vous n’avez pas trouvé la réponse que vous recherchez ?
lionyz
Messages postés62Date d'inscriptionsamedi 10 janvier 2009StatutMembreDernière intervention30 octobre 2012 24 mars 2009 à 14:47
Merci pour cet exemple.
Tout est clair sauf l'expression après '.Pattern ='
qui est pour moi un peu comme du chinois
je suppose que ça à voir avec le HTML
Private Sub Command1_Click()
Dim oDoc As HTMLDocument
Dim oMatch As Object
Dim oBody As Object
Set oDoc = WebBrowser1.Document
If Not Nothing Is oDoc Then
Set oBody = oDoc.getElementsByTagName("body")
If oBody.length > 0 Then
Set oBody = oBody.Item(0)
For Each oMatch In .Execute(oBody.innerHTML)
MsgBox "Nom: " & oMatch.SubMatches(0) & vbNewLine & _
"Premier: " & oMatch.SubMatches(1) & vbNewLine & _
"+Haut: " & oMatch.SubMatches(2) & vbNewLine & _
"+Bas: " & oMatch.SubMatches(3) & vbNewLine & _
"volume: " & oMatch.SubMatches(4) & vbNewLine & _
"Veille: " & oMatch.SubMatches(5) & vbNewLine & _
"Dernier: " & oMatch.SubMatches(6), vbInformation
Next oMatch
End With
End If
End If
End Sub
Private Sub Form_Load()
WebBrowser1.Navigate2 SOURCE_URL
End Sub
Private Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
Command1.Enabled = False
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant) Command1.Enabled (URL SOURCE_URL)
End Sub
Merci par avance d'éclairer ma lanterne. En tout cas, c'est un peu ch... au début, mais faut reconnaître que c'est puissant !!!
Private Sub Command1_Click()
Dim oDoc As HTMLDocument
Dim oMatch As Match
Dim oMatches As MatchCollection
Dim oBody As Object
Dim sContent As String
Dim nPos As Long
Dim nRow As Long
With MSFlexGrid1
.cols = 7
.rows = 2
.FixedCols = 1
.FixedRows = 1
Set oDoc = WebBrowser1.document
If Not Nothing Is oDoc Then
Set oBody = oDoc.getElementsByTagName("body")
If oBody.length = 1 Then
Set oBody = oBody.Item(0)
sContent = oBody.innerHTML
nPos = InStr(sContent, "../graphes")
If nPos Then
sContent = Mid$(sContent, nPos - 10)
nPos = InStr(sContent, "</TABLE>")
If nPos Then
sContent = Left$(sContent, nPos - 10)
sContent = Replace(sContent, " ", vbNullString)
With New RegExp
.Pattern = ">([^<]+).+\s.+\s.+>(\d+,\d+).+\s.+>(\d+,\d+).+\s.+>(\d+,\d+).+\s.+>(\d+).+\s.+>(\d+,\d+).+\s.+>(\d+,\d+).+\s.+\s.+>(-?\d+,\d+)%"
.Global = True
.MultiLine = True
Set oMatches = .Execute(sContent)
MSFlexGrid1.rows = 1 + oMatches.Count
For Each oMatch In oMatches
nRow = nRow + 1
MSFlexGrid1.TextMatrix(nRow, 0) = oMatch.SubMatches(0)
MSFlexGrid1.TextMatrix(nRow, 1) = oMatch.SubMatches(1)
MSFlexGrid1.TextMatrix(nRow, 2) = oMatch.SubMatches(2)
MSFlexGrid1.TextMatrix(nRow, 3) = oMatch.SubMatches(3)
MSFlexGrid1.TextMatrix(nRow, 4) = oMatch.SubMatches(4)
MSFlexGrid1.TextMatrix(nRow, 5) = oMatch.SubMatches(5)
MSFlexGrid1.TextMatrix(nRow, 6) = oMatch.SubMatches(6)
Next oMatch
End With
End If
End If
End If
End If
End Sub
Private Sub Form_Load()
WebBrowser1.Navigate2 SOURCE_URL & "?L=A"
End Sub
Private Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
Command1.Enabled = False
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Command1.Enabled (Left$(URL, Len(URL) - 4) SOURCE_URL)
End Sub
moscato40
Messages postés27Date d'inscriptionmardi 13 mai 2008StatutMembreDernière intervention24 juin 2010 27 mars 2009 à 13:50
Salut,
Ca marche nickel. Ta solution est plus simple et plus efficace que la mienne (et elle n'oublie pas de valeur en route !!!). Tu as même devancé mon projet de le mettre dans un MSflexgrid. Tu serais pas un peu voyant extra-lucide ???
En tout cas, j'abandonne pas et je continue à bouffer du regexp pour arrêter de te solliciter tous les quatre matins.
Je note que ça fait 2 solutions complètes que tu "m'offres" mais surtout ça fait 2 cas d'école que je vais essayer de bien analyser et de bien maîtriser.
Comme on dis jamais 2 sans 3, je te dis à la prochaine. Je vais essayer de te trouver un truc un peu plus balèze. J'ai hâte, comme ça je me coucherai un peu moins c... quand tu m'auras proposer ta soluce !!
Bien sur je peux enregistrer les données sur un fichier texte externe mais ça me plait pas. Ce qui m'énnerve, c'est que je suis persuadé que je suis tout près et qu'il ne suffit que de simples modifs sur ta solution pour y arriver.
Si ca se trouve, je suis complètement dans l'erreur. Tu pourrais pas me mettre sur la voie stp.
moscato40
Messages postés27Date d'inscriptionmardi 13 mai 2008StatutMembreDernière intervention24 juin 2010 23 avril 2009 à 15:59
C'est le MSFlexGrid1.TextMatrix(nRow, 0) :
Run-time error '381'
Subscript out of range
Pour ta boule de cristal, on va monter une grande opération humanitaire. Je pense qu'on va réussir à t'en dégoter une. Donnes-nous la référence que tu veux.
Je continue à mettre les mains dans le camboui de mon côté. C'est rigolo.
moscato40
Messages postés27Date d'inscriptionmardi 13 mai 2008StatutMembreDernière intervention24 juin 2010 23 avril 2009 à 17:41
C'est bon j'ai trouvé.
Par contre, quand je parcours les différentes pages de cotations, pour ne pas que le flexgrid se vide, je dois stocker le nombre de lignes après chaque insertion des données dans le flexgrid dans un textbox ou un label. C'est la seule solution possible ?