Copy data from HTML











up vote
1
down vote

favorite












I am trying to learn how to parse data from HTML using Excel VBA. So I found one example online which works fine but when I change URL address from www.yahoo.com to local HTML file on C it gives me error i.e. Method 'busy' of object 'IwebBrowser2' failed. Code is:



Sub GetBodyText()

Dim URL As String
Dim Data As String

URL = "file:///C:/test.html"

Dim ie As Object
Dim ieDoc As Object

Set ie = CreateObject("InternetExplorer.Application")
ie.navigate URL

Do Until (ie.readyState = 4 And Not ie.Busy)
DoEvents
Loop

Set ieDoc = ie.Document

Data = ieDoc.body.innerText

'Split Data into separate lines
'or just use Range("A1")=data
Dim myarray As Variant
myarray = Split(Data, vbCrLf)

For i = 0 To UBound(myarray)
'Start writing in cell A1
Cells(i + 1, 1) = myarray(i)
Next


ie.Quit
Set ie = Nothing
Set ieDoc = Nothing

End Sub









share|improve this question




















  • 1




    Will your final result be parsing a file or parsing a page? You can pull the data from the file or the web page without loading an InternetExplorer.Application object.
    – Tom Hines
    Jun 2 '17 at 18:56

















up vote
1
down vote

favorite












I am trying to learn how to parse data from HTML using Excel VBA. So I found one example online which works fine but when I change URL address from www.yahoo.com to local HTML file on C it gives me error i.e. Method 'busy' of object 'IwebBrowser2' failed. Code is:



Sub GetBodyText()

Dim URL As String
Dim Data As String

URL = "file:///C:/test.html"

Dim ie As Object
Dim ieDoc As Object

Set ie = CreateObject("InternetExplorer.Application")
ie.navigate URL

Do Until (ie.readyState = 4 And Not ie.Busy)
DoEvents
Loop

Set ieDoc = ie.Document

Data = ieDoc.body.innerText

'Split Data into separate lines
'or just use Range("A1")=data
Dim myarray As Variant
myarray = Split(Data, vbCrLf)

For i = 0 To UBound(myarray)
'Start writing in cell A1
Cells(i + 1, 1) = myarray(i)
Next


ie.Quit
Set ie = Nothing
Set ieDoc = Nothing

End Sub









share|improve this question




















  • 1




    Will your final result be parsing a file or parsing a page? You can pull the data from the file or the web page without loading an InternetExplorer.Application object.
    – Tom Hines
    Jun 2 '17 at 18:56















up vote
1
down vote

favorite









up vote
1
down vote

favorite











I am trying to learn how to parse data from HTML using Excel VBA. So I found one example online which works fine but when I change URL address from www.yahoo.com to local HTML file on C it gives me error i.e. Method 'busy' of object 'IwebBrowser2' failed. Code is:



Sub GetBodyText()

Dim URL As String
Dim Data As String

URL = "file:///C:/test.html"

Dim ie As Object
Dim ieDoc As Object

Set ie = CreateObject("InternetExplorer.Application")
ie.navigate URL

Do Until (ie.readyState = 4 And Not ie.Busy)
DoEvents
Loop

Set ieDoc = ie.Document

Data = ieDoc.body.innerText

'Split Data into separate lines
'or just use Range("A1")=data
Dim myarray As Variant
myarray = Split(Data, vbCrLf)

For i = 0 To UBound(myarray)
'Start writing in cell A1
Cells(i + 1, 1) = myarray(i)
Next


ie.Quit
Set ie = Nothing
Set ieDoc = Nothing

End Sub









share|improve this question















I am trying to learn how to parse data from HTML using Excel VBA. So I found one example online which works fine but when I change URL address from www.yahoo.com to local HTML file on C it gives me error i.e. Method 'busy' of object 'IwebBrowser2' failed. Code is:



Sub GetBodyText()

Dim URL As String
Dim Data As String

URL = "file:///C:/test.html"

Dim ie As Object
Dim ieDoc As Object

Set ie = CreateObject("InternetExplorer.Application")
ie.navigate URL

Do Until (ie.readyState = 4 And Not ie.Busy)
DoEvents
Loop

Set ieDoc = ie.Document

Data = ieDoc.body.innerText

'Split Data into separate lines
'or just use Range("A1")=data
Dim myarray As Variant
myarray = Split(Data, vbCrLf)

For i = 0 To UBound(myarray)
'Start writing in cell A1
Cells(i + 1, 1) = myarray(i)
Next


ie.Quit
Set ie = Nothing
Set ieDoc = Nothing

End Sub






html excel parsing vba






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 23 '15 at 5:00









pnuts

46.4k76195




46.4k76195










asked Sep 13 '13 at 14:52









user2774120

2327




2327








  • 1




    Will your final result be parsing a file or parsing a page? You can pull the data from the file or the web page without loading an InternetExplorer.Application object.
    – Tom Hines
    Jun 2 '17 at 18:56
















  • 1




    Will your final result be parsing a file or parsing a page? You can pull the data from the file or the web page without loading an InternetExplorer.Application object.
    – Tom Hines
    Jun 2 '17 at 18:56










1




1




Will your final result be parsing a file or parsing a page? You can pull the data from the file or the web page without loading an InternetExplorer.Application object.
– Tom Hines
Jun 2 '17 at 18:56






Will your final result be parsing a file or parsing a page? You can pull the data from the file or the web page without loading an InternetExplorer.Application object.
– Tom Hines
Jun 2 '17 at 18:56














1 Answer
1






active

oldest

votes

















up vote
0
down vote













For IE, just use:



URL = "c:test.html"





share|improve this answer





















  • Hi Thanks, But i am still getting same error. Is it because there is prompt for "Enable Active x" when i open local html file ?
    – user2774120
    Sep 13 '13 at 15:03










  • Possibly, but it worked for me. Try this: just before ie.navigate URL, add ie.visible=true. This will actually display the IE window, so it should show you what's holding it up.
    – Joe
    Sep 13 '13 at 15:10











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f18789316%2fcopy-data-from-html%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













For IE, just use:



URL = "c:test.html"





share|improve this answer





















  • Hi Thanks, But i am still getting same error. Is it because there is prompt for "Enable Active x" when i open local html file ?
    – user2774120
    Sep 13 '13 at 15:03










  • Possibly, but it worked for me. Try this: just before ie.navigate URL, add ie.visible=true. This will actually display the IE window, so it should show you what's holding it up.
    – Joe
    Sep 13 '13 at 15:10















up vote
0
down vote













For IE, just use:



URL = "c:test.html"





share|improve this answer





















  • Hi Thanks, But i am still getting same error. Is it because there is prompt for "Enable Active x" when i open local html file ?
    – user2774120
    Sep 13 '13 at 15:03










  • Possibly, but it worked for me. Try this: just before ie.navigate URL, add ie.visible=true. This will actually display the IE window, so it should show you what's holding it up.
    – Joe
    Sep 13 '13 at 15:10













up vote
0
down vote










up vote
0
down vote









For IE, just use:



URL = "c:test.html"





share|improve this answer












For IE, just use:



URL = "c:test.html"






share|improve this answer












share|improve this answer



share|improve this answer










answered Sep 13 '13 at 14:57









Joe

6,02711025




6,02711025












  • Hi Thanks, But i am still getting same error. Is it because there is prompt for "Enable Active x" when i open local html file ?
    – user2774120
    Sep 13 '13 at 15:03










  • Possibly, but it worked for me. Try this: just before ie.navigate URL, add ie.visible=true. This will actually display the IE window, so it should show you what's holding it up.
    – Joe
    Sep 13 '13 at 15:10


















  • Hi Thanks, But i am still getting same error. Is it because there is prompt for "Enable Active x" when i open local html file ?
    – user2774120
    Sep 13 '13 at 15:03










  • Possibly, but it worked for me. Try this: just before ie.navigate URL, add ie.visible=true. This will actually display the IE window, so it should show you what's holding it up.
    – Joe
    Sep 13 '13 at 15:10
















Hi Thanks, But i am still getting same error. Is it because there is prompt for "Enable Active x" when i open local html file ?
– user2774120
Sep 13 '13 at 15:03




Hi Thanks, But i am still getting same error. Is it because there is prompt for "Enable Active x" when i open local html file ?
– user2774120
Sep 13 '13 at 15:03












Possibly, but it worked for me. Try this: just before ie.navigate URL, add ie.visible=true. This will actually display the IE window, so it should show you what's holding it up.
– Joe
Sep 13 '13 at 15:10




Possibly, but it worked for me. Try this: just before ie.navigate URL, add ie.visible=true. This will actually display the IE window, so it should show you what's holding it up.
– Joe
Sep 13 '13 at 15:10


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f18789316%2fcopy-data-from-html%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

List item for chat from Array inside array React Native

Thiostrepton

Caerphilly