Extraction données formulaire Word vers Excel
jojolafripouille
Messages postés
2
Statut
Membre
-
jojolafripouille Messages postés 2 Statut Membre -
jojolafripouille Messages postés 2 Statut Membre -
Bonjour,
J'ai réalisé un formulaire sur Word à l'aide de boutons radio (ou option button). Je souhaite pouvoir extraire les données afin de les traiter dans un tableur Excel. Voici le code que j'ai fait :
Dim appWord As Word.Application
Set appWord = CreateObject(Class:="Word.Application")
appWord.Visible = True
appWord.Documents.Open Filename:=pathToDocument, ReadOnly:=True
Dim DocWord As Word.Document
Set DocWord = GetObject(pathToDocument)
DocWord.Activate
j = 1
iField = 1
iQuestion = 0
iPart = 0
Dim oShape As Word.InlineShape
For Each oShape In DocWord.InlineShapes()
Dim myObj As Object
*With oShape.OLEFormat.Activate
Set myObj = oShape.OLEFormat.Object
End With
If myObj.Value = True Then
Application.Workbooks(1).Worksheets(iPart + 1).Cells(i, j).Value = 1
Else
Application.Workbooks(1).Worksheets(iPart + 1).Cells(i, j).Value = 0
End If
(...)
Le gros problème est que j'ai toujours le même message d'erreur qui s'affiche :
"Object Variable or With Block Variable not Set". Quand je debug, il me surligne la ligne * en me disant que myObj = nothing.
Est-ce que quelqu'un saurait m'aider ? Pour info, je suis sous Office 2010.
Merci d'avance !
J'ai réalisé un formulaire sur Word à l'aide de boutons radio (ou option button). Je souhaite pouvoir extraire les données afin de les traiter dans un tableur Excel. Voici le code que j'ai fait :
Dim appWord As Word.Application
Set appWord = CreateObject(Class:="Word.Application")
appWord.Visible = True
appWord.Documents.Open Filename:=pathToDocument, ReadOnly:=True
Dim DocWord As Word.Document
Set DocWord = GetObject(pathToDocument)
DocWord.Activate
j = 1
iField = 1
iQuestion = 0
iPart = 0
Dim oShape As Word.InlineShape
For Each oShape In DocWord.InlineShapes()
Dim myObj As Object
*With oShape.OLEFormat.Activate
Set myObj = oShape.OLEFormat.Object
End With
If myObj.Value = True Then
Application.Workbooks(1).Worksheets(iPart + 1).Cells(i, j).Value = 1
Else
Application.Workbooks(1).Worksheets(iPart + 1).Cells(i, j).Value = 0
End If
(...)
Le gros problème est que j'ai toujours le même message d'erreur qui s'affiche :
"Object Variable or With Block Variable not Set". Quand je debug, il me surligne la ligne * en me disant que myObj = nothing.
Est-ce que quelqu'un saurait m'aider ? Pour info, je suis sous Office 2010.
Merci d'avance !
A voir également:
- Extraction données formulaire Word vers Excel
- Whatsapp formulaire opposition - Guide
- Word et excel gratuit - Guide
- Word 2013 - Télécharger - Traitement de texte
- Tableau word - Guide
- Liste déroulante excel - Guide
2 réponses
J'ai essayé avec :
For Each oShape In DocWord.Shapes()
Dim myObj As Object
Set myObj = oShape.OLEFormat.Object
If myObj.Value = True Then
Application.Workbooks(1).Worksheets(iPart + 1).Cells(i, j).Value = 1
Else
Application.Workbooks(1).Worksheets(iPart + 1).Cells(i, j).Value = 0
End If
Ca ne marche toujours pas...
For Each oShape In DocWord.Shapes()
Dim myObj As Object
Set myObj = oShape.OLEFormat.Object
If myObj.Value = True Then
Application.Workbooks(1).Worksheets(iPart + 1).Cells(i, j).Value = 1
Else
Application.Workbooks(1).Worksheets(iPart + 1).Cells(i, j).Value = 0
End If
Ca ne marche toujours pas...