VB - Récupérer la mise à jour d'un blog

Résolu/Fermé
laguernette Messages postés 6 Date d'inscription lundi 27 février 2012 Statut Membre Dernière intervention 31 mars 2012 - 27 mars 2012 à 16:25
laguernette Messages postés 6 Date d'inscription lundi 27 février 2012 Statut Membre Dernière intervention 31 mars 2012 - 31 mars 2012 à 16:24
Bonjour,

Je cherche à récupérer dans une textbox la dernière mise à jour d'un blog. Pouvez-vous m'aider svp ?

J'ai essayé avec webrequest mais ne maîtrisant pas la fonction, j'ai échoué.
J'ai aussi essayé une méthode dérivée en ouvrant le site web avec excel mais mon code ne semble pas être correct :

 
 Dim appExcel As Excel.Application
 Dim wbExcel As Excel.Workbook
 Dim wsExcel As Excel.Worksheet
 Dim ValAChercher, ValARenvoyer
 Dim c As Range

        appExcel = CreateObject("Excel.Application")
         wbExcel = appExcel.Workbooks.Open("http://autocyclettes.free.fr/")
         wsExcel = wbExcel.Worksheets(1) 'wsExcel 

        ValAChercher = "Mise à jour :"

        With wsExcel.Range("a1:a500")
            c = .Find(ValAChercher)
            If Not c Is Nothing Then
                ValARenvoyer = c.Offset(0, 1).Value
                Textbox1.text = ValARenvoyer
            End If
         End With


A voir également:

2 réponses

PenguinFlash Messages postés 158 Date d'inscription mardi 30 août 2011 Statut Membre Dernière intervention 31 mars 2015 7
27 mars 2012 à 22:10
le form1.vb :

Imports System.Net.Mime.MediaTypeNames

Public Class Form1

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim appExcel As Application
Dim wbExcel As Excel.Worksheet
Dim wsExcel As Excel.Worksheet
Dim ValAChercher, ValARenvoyer
Dim c As Range

appExcel = CreateObject("Excel.Application")
wbExcel = appExcel.Workbooks.Open("http://autocyclettes.free.fr/")
wsExcel = wbExcel.Worksheets(1) 'wsExcel

ValAChercher = "Mise à jour :"

With wsExcel.Range("a1:a500")
c = .Find(ValAChercher)
If Not c Is Nothing Then
ValARenvoyer = c.Offset(0, 1).Value
TextBox1.Text = ValARenvoyer
End If
End With

End Sub
End Class

Le WorkSheet.vb:

Namespace Excel
Class Worksheet

Function Worksheets(p1 As Integer) As Worksheet
Throw New NotImplementedException
End Function

Function Range(p1 As String) As Object
Throw New NotImplementedException
End Function

End Class
End Namespace
0
laguernette Messages postés 6 Date d'inscription lundi 27 février 2012 Statut Membre Dernière intervention 31 mars 2012
31 mars 2012 à 16:24
Merci, mais j'ai finalement opté pour la solution suivante :

 Dim appExcel As Excel.Application 'Application Excel
        Dim wbExcel As Excel.Workbook 'Classeur Excel
        Dim wsExcel As Excel.Worksheet 'Feuille Excel

        'Déclaration des variables
        appExcel = CreateObject("Excel.Application")
        'Ouverture de l'application Excel
        wbExcel = appExcel.Workbooks.Open("http://autocyclettes.free.fr")
        'Ouverture d'un fichier Excel
        wsExcel = wbExcel.Worksheets(1) 'wsExcel 

        Dim Maj As Integer
        Dim Chr As Integer
        For Maj = 1 To 650
            If InStr(wsExcel.Range("A" & Maj).Value, "Updated") <> 0 Then
                TextBox1.Text = "Le mot - Updated - existe dans la cellule A" & Maj
                TextBox2.Text = InStr(wsExcel.Range("A" & Maj).Value, "Updated")
                Chr = TextBox2.Text
                TextBox3.Text = Microsoft.VisualBasic.Mid(wsExcel.Range("A" & Maj).Value, Chr + 9, 8)
            End If
        Next Maj


        wbExcel.Close(False) '(referme la page Web) 
        appExcel.Quit() 'Fermeture de l'application Excel
        wsExcel = Nothing 'Désallocation mémoire
        wbExcel = Nothing 'Désallocation mémoire
        appExcel = Nothing 'Désallocation mémoire
0