[英]Macro to import local .html file to excel
I have an Excel spreadsheet which compares data from a TXT file with a UDL file. 我有一个Excel电子表格,可以将TXT文件中的数据与UDL文件进行比较。 These formats import easily into my spreadsheet. 这些格式可以轻松导入我的电子表格中。
Then I attempted to import a locally stored .html file into this spreadsheet through a macro button, I did not succeed writing my own code nor finding correct code on the internet. 然后,我尝试通过宏按钮将本地存储的.html文件导入此电子表格,但未成功编写自己的代码,也未在互联网上找到正确的代码。
What I need help with: 我需要什么帮助:
My .HTML file converts perfectly to xlsx with the code below: 我的.HTML文件使用以下代码完美转换为xlsx:
Sub Open_HTML_Save_XLSX()
Workbooks.Open Filename:="C:\Temp\Example.html"
ActiveWorkbook.SaveAs Filename:= _
"C:\Temp\Example.xlsx", FileFormat:= _
xlOpenXMLWorkbook
End Sub
Thank you Alok Singh for your input. 谢谢Alok Singh的投入。 I managed to answer my question on my own, sorry for the inconvenience :). 我设法自己回答了我的问题,不便之处,敬请原谅。 posting my answer below 在下面发布我的答案
Sub Button_click()
Range("A1:s1000").Clear
Dim OpenFileName As String
Dim wb As Workbook
OpenFileName = Application.GetOpenFilename("Your .HTML file ,*.html")
If OpenFileName = "False" Then Exit Sub
Set wb = Workbooks.Open(OpenFileName)
ThisWorkbook.Sheets(1).Range("a1:s1000").Value = wb.Sheets(1).Range("a1:s1000").Value
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.