Link to home
Start Free TrialLog in
Avatar of SAIMSKY ADMIN
SAIMSKY ADMINFlag for Spain

asked on

How to import Multiply html files in one Excel file in different sheets

I have exported all my GPOs in html files , now I want to make one excel file of these html files. I want each GPO in each spread sheet.

Please advise
Avatar of Glenn Ray
Glenn Ray
Flag of United States of America image

You can open HTML files in Excel using the regular Open file command and filter on just *.html, *.htm file types.

If all your GPO files are in the same directory, a macro could be written to open each file and save on its own sheet in a new workbook.

-Glenn
Avatar of SAIMSKY ADMIN

ASKER

Can u plz guide me , I tired but still not able to doit, if u can guide me with the screen shots . Many thanks
To open an HTML file:
Menu:  File --> Open
Change the file type filter on the bottom right to "All Web Pages (*.htm;*.html;...)"
Browse and find any GPO file, then click Open.
User generated imageYou could do this for each file, copy and paste (or copy sheet) each result into one workbook.

-Glenn
Thanks Glenn,

Actually I need all html files in one excel file.

Can you please guide me hoe to use marco, I found one marco but dont know to use in excel file.

Sub Pull_html()
Dim z  As Long, e As Long
Dim f As String, m As String, n As String
Sheets("Sheet1").Select
Cells(1, 1) = "=cell(""filename"")"
Cells(1, 2) = "=left(A1,find(""["",A1)-1)"
Cells(2, 1).Select
f = Dir(Cells(1, 2) & "*.htm")
Do While Len(f) > 0
ActiveCell.Formula = f
ActiveCell.Offset(1, 0).Select
f = Dir()
Loop
z = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
For e = 2 To z
n = Sheets("Sheet1").Cells(e, 1)
If n <> ActiveWorkbook.Name Then
If Len(n) < 35 Then
m = Left(n, Len(n) - 4)
Else
m = Left(n, 31)
End If
Sheets.Add.Name = m
With ActiveSheet.QueryTables.Add(Connection:="URL;file:///" & Sheets("Sheet1").Cells(1, 2) & Sheets("Sheet1").Cells(e, 1), _
        Destination:=Sheets(m).Range("A1"))
        .Name = "goodbites"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlEntirePage
        .WebFormatting = xlWebFormattingNone
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .Refresh BackgroundQuery:=False
    End With
End If
Next e
MsgBox "collating is complete."
End Sub
That macro looks okay; I could modify it and insert into a workbook so that you could browse to the folder with the files and then it would combine them.  I will be away for an hour, but will work on this when I return.

-Glenn
Many many thanks
Hi Mate Glenn,

Can you please help me in this ?
ASKER CERTIFIED SOLUTION
Avatar of Glenn Ray
Glenn Ray
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Many Many thanks Glenn, You are crack.
Excellent work done, Super!!!!!
Hi Glenn,

Many thanks , Need anther Marco setting , please if you can help me. I need to set hyperlink for html files in excel file. I have GPO html files in folder and in another excel file I have Summary of GPOs , what i want of I click on the name of GPO it will open html file of that GPO.

CH-HONGKONG_ACCOUNTS_USERS  > CH-HONGKONG_ACCOUNTS_USERS,html
Avatar of John Titor
John Titor

Hi Glenn,

Can you also import multiple html to single sheet on excel thank you. awesome work.