Share via

Import html table to Excel Macro

Anonymous
2014-01-17T09:33:56+00:00

Pls help to get imported table to excel.

Html code....

function displaytagform(formname, fields){

    var objfrm = document.forms[formname];

    for (j=fields.length-1;j>=0;j--){var f= objfrm.elements[fields[j].f];if (f){f.value=fields[j].v};}

    objfrm.submit();

}

</script><div class="pagelinks" align="right">[First/Prev] <strong>1</strong>, <a href="javascript:displaytagform('miscellaneousForm',[{f:'d-7876840-p',v:'2'}])" title="Go to page 2">2</a>, <a href="javascript:displaytagform('miscellaneousForm',[{f:'d-7876840-p',v:'3'}])" title="Go to page 3">3</a>, <a href="javascript:displaytagform('miscellaneousForm',[{f:'d-7876840-p',v:'4'}])" title="Go to page 4">4</a>, <a href="javascript:displaytagform('miscellaneousForm',[{f:'d-7876840-p',v:'5'}])" title="Go to page 5">5</a>, <a href="javascript:displaytagform('miscellaneousForm',[{f:'d-7876840-p',v:'6'}])" title="Go to page 6">6</a>, <a href="javascript:displaytagform('miscellaneousForm',[{f:'d-7876840-p',v:'7'}])" title="Go to page 7">7</a>, <a href="javascript:displaytagform('miscellaneousForm',[{f:'d-7876840-p',v:'8'}])" title="Go to page 8">8</a> [<a href="javascript:displaytagform('miscellaneousForm',[{f:'d-7876840-p',v:'2'}])">Next</a>/<a href="javascript:displaytagform('miscellaneousForm',[{f:'d-7876840-p',v:'13'}])">Last</a>]</div>

<table id="DTRDetailObject" style="width:100%" cellpadding="0" class="intablehead1" cellspacing="1">

<thead>

<tr>

<th><input type="checkbox" name="allbox" onclick="checkAll(document.forms[0])"></th>

<th>Requested Date</th>

<th>Customer MSISDN</th>

<th>POS Code</th>

<th>POS Name</th>

<th>POS MSISDN</th>

<th>Customer Name</th>

<th>MNP No</th></tr></thead>

<tbody>

<tr class="intablerow12">

<td>

                                      <div align="center"><input type="checkbox" name="dtrappovedList[0].strSelected" value="on">

                                            <input type="hidden" name="dtrappovedList[0].strSelected" value=""></div>

                                        </td>

<td class="centeralign">2014-01-02 10:09:30</td>

<td class="centeralign">8409</td>

<td class="centeralign">PSBJPATN0285886</td>

<td class="centeralign">SHIV SHAKTI </td>

<td class="centeralign">91222</td>

<td class="centeralign">K KUMAR</td>

<td class="centeralign"></td></tr>

<tr class="intablerow11">

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

4 answers

Sort by: Most helpful
  1. Anonymous
    2014-03-11T07:48:43+00:00

    It didn't help so far.

    The JavaScript is of a  live webpage.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2014-03-08T10:47:27+00:00

    Hi,

    i am not familiar with  javascript

    but try this...

    assuming that you have an .htm file,

    in path

    "c:\FilesHTML\sample1.htm"

    [Edit..Mar 11,2014]

    Sub OpenXTML_01()

    Dim myWB As Workbook, wb As Workbook

    Dim ws As Worksheet

    Dim myPath

    myPath= "c:\FilesHTML\sample1.htm"   '<< change

    Set myWB = ThisWorkbook

    Set wb = Workbooks.Open(myPath)

    For x = 1 To wb.Sheets.Count

    wb.Sheets(x).Copy after:=myWB.Sheets(myWB.Sheets.Count)

    wb.Sheets(x).UsedRange.EntireColumn.AutoFit

    Next

    wb.Close False

    myWB.Save

    End Sub

    XXXXXXXXXXXXXXXXXXX

    or

    download a htm file from a URL Address

    like this....

    [Edit..]

    Sub Web_Query_Method()

    Sheets.Add

    With ActiveSheet.QueryTables.Add(Connection:= _

    "URL;http://www.w3schools.com/html/html_tables.asp", Destination:=Range("A1"))

    .FieldNames = True

    .RowNumbers = False

    .FillAdjacentFormulas = False

    .PreserveFormatting = True

    .RefreshOnFileOpen = False

    .BackgroundQuery = True

    .RefreshStyle = xlInsertDeleteCells

    .SavePassword = False

    .SaveData = True

    .AdjustColumnWidth = False 'True

    .RefreshPeriod = 0

    .WebSelectionType = xlSpecifiedTables

    .WebFormatting = xlWebFormattingNone

    .WebTables = "1" 'or "1,2"

    .WebPreFormattedTextToColumns = True

    .WebConsecutiveDelimitersAsOne = True

    .WebSingleBlockTextImport = False

    .WebDisableDateRecognition = False

    .WebDisableRedirections = False

    .Refresh BackgroundQuery:=False

    End With

    End Sub

    also,

    "url;http://www.hsfdatabase.com/tn_greenbrier2000.htm"

    and..

    play with this in specific url...

    "url;http://finance.yahoo.com/q?s=aa"

    .WebTables = "1" 'or "1,2" or "1,2,3,4,5,6" or "3,4" or "6"

    and..

    "url;http://finance.yahoo.com/q?s=1" 'replace 1 with 2,3,4..

    .WebTables = "1,2"

    note

    general,

    most common is: "1" or "1,2"

    and

    usually, max number of tbs is 20

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2014-03-07T10:17:09+00:00

    Dear All,

    Waiting for any help on the same!!!

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2014-01-24T20:04:38+00:00

    Hi

    Pls help as I am not much familiar with HTML.

    Was this answer helpful?

    0 comments No comments