I would need to get HTML source code from any given page. I know how to open a HTML page from Excel and I can do it with VBA, but how to get for example this page's source code?
I would start with making a sub that takes a string (the address) as an input parameter and finish with saving the source code of that address as an text file like c:code.txt
So something like
Dim webaddress as string
Sub GetSourceCode(webaddress)
'then some code to save the source code
End Sub
I have previously used the following code to successfully pull out IE webpage source code for string manipulation.
Its a crude example to demonstrate the principle:
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Public IE As Object Sub Sample() Set IE = CreateObject("InternetExplorer.Application") IE.Visible = True
[Code] ......
However when I substitute in a Google websites address into the IE.Navigate command, the code runs to the "Source_Code = IE.document ...." line then flags up a Microsoft Visual Basic error. "Run-time error '438': Object doesn't support this property or method"
The webpage that I am trying to access is a confidential company site, so you won't be able to access it yourself, but starts with [URL] ......
The one thing that I have noticed about this website is the Privacy Report icon in the lower right status window (Picture of an eye with a restricted symbol in front). I don't know whether this is the cause of my problem, or purely an incidental observation.
Is there something peculiar with Google sites that means that the source code cannot be extracted in general, or is this an issue specific to my site ? Does the Privacy Report icon have any relevance, and if so how do I switch that off ?
I need to check a website daily to see if a link has been updated. If it has been updated, the beginning of the link changes to a different date. Example: today link is www.10212009dave.com and tomorrow link may be www.10222009dave.com. Lets say the link is on www.gugg.com. The link does not change everyday, but I think a good way to see if it has been updated is to search through the source code in the html for that link.
Thus I would put www.10212009dave.com into cell A1 and tell excel to search the source code on www.gugg.com, and if the contents of cell A1 is NOT found, I'd display a message box stating the link has been updated.
I am looking to read the source code for a website that keeps the stats for a hockey league in Sweden
For other sites i can use the code below and it works fine, but the site i am using to get the Sweden stats seem to keep the data in some type of a Java app (sorry still somewhat of a newbie) and doesn't work the same as the others
when i veiw the source code just by right clicking the page all the data i want shows up. When i try to use my code it doesn't get the stuff i want.
I have tried both objDoc.body.innerHTML and objDoc.body.outerHTML and i get different results but not the same as right clicking on the page and viewing the source, is there another command that i can use to get it all?
the website is
HTML [url]
Sub Get_Stats() Const strURIpre As String = [url] Set ie = CreateObject("internetexplorer.application") ie.Navigate strURIpre Do If ie.ReadyState = 4 Then ie.Visible = False Exit Do Else
I would like to retrieve contents of a web page, be it HTML or XML, into VBA variable!
Later, I would chop, cut, parse or extract the data I need.
Both importing as XML or WebQueries is unsatisfactory for a certain number of pages I need. XML has bad schema, WebQuery tells me it can't find any data.
I tried with WinHTTPRequest, but Excel gives me back error "undefined user type" in other words it doesn't recognize that object.
Basically I want the source of web page to become a string in my VBA code. In other words that would be replication of funcionallity of
I need to do seems quite simple, I want to grab the source of a webpage into a string (where I'll then to some fiddling about with it to strip it down to the information which I need). Currently I'm trying to do it using the webbrowser object and meddling around with the .document properties, but I can't figure it out.
Goal: I have data that was copied to my clipboard from the webpage source in a Chrome browser. I would like to get that data over to my excel worksheet and insert it starting at "A1".
Issue: All of the pasted data is ending up in ONLY cell "A1" when using VBA.
When I just click in cell "A1" and CTRL-V, the data gets spread across a lot of cells, which is what I am after.
Code: '------------------------------------------ 'Start The Process '------------------------------------------
' Assigning clipboard data to string variable strClip
Dim MyData As DataObject Dim strClip As String
Set MyData = New DataObject MyData.GetFromClipboard
I have modified the export a range to HTML code from Mr Walkenbachs excellent book and it all works well (still learning my trade with vba!!). The only issue I have is when the code a save as dialogue box appears. As I am looking to automate this process I was hoping to get this code to automatically save preferably to a path ("c:dailyrange.htm" for eg). I have tried various permutations but am really struggling with the concept.
I am using excel 2003.
The code
Sub ExportToHTML() ' Dim ws As Worksheet Dim Filename As Variant Dim TDOpenTag As String, TDCloseTag As String Dim CellContents As String Dim Rng As Range Dim r As Long, c As Integer
'Create 7 htmls one for each column of the specified range For Column = 1 To 7 Range(Cells(14, Column), Cells(40, Column)).Select ' Use the selected range of cells Set Rng = Application.Intersect(ActiveSheet.UsedRange, Selection)
I have excel 2003 and I have a macro that sorts data and then saves it as an HMTL page. When I was upgraded to excel 2003, it started saving the sheet as 'mhtml', which is causing me other problems. using:
With ActiveWorkbook.PublishObjects.Add(xlSourceRange, _ "C:Documents and Settings holg1My DocumentsQCMA events2007 est.htm" _ , "Event", saverange, xlHtmlStatic, "total_points_2007_8160", "") .Publish (True) .AutoRepublish = False End With
with a defined document name (test.htm), it works (saves as html doc). using:
eventname = "jan22"
With ActiveWorkbook.PublishObjects.Add(xlSourceRange, _ eventname, "Event", _ saverange, xlHtmlStatic, "total_points_24036", "") .Publish (True) .AutoRepublish = False End With
with a variable document name (jan22), it saves as mhtml. How do I make it save as an HTML doc instead of an MHTML doc?
I have received several hundred "Excel" data file dumps from an unspecified corporate database ( SAP? ). They are nominally spreadsheets, that is they are tables of mixed data that Excel recognizes, as they are exported from the database as such.
I'd like to walk a directory containing these files, and only these files, open each in turn save them as proper Excel files and close them. The end goal is to import these tables into a Access database, but Access doesn't recognize them either. I also need to repair values in one field which is easier to accomplish in Excel.
Unfortunately, opening the file generates an error I've been unable to trap, due to the fact the excel thinks its an HTML file, which it is, and wants me to verify that I do want to open it. Similarly, I receive a message when I try to save the file that requires me to nominate an acceptable Excel file type, which I can do in code.
Taking advantage of csv files and importing into websites. Basically I have a html code in a cell which needs to pick out content from different cells in the same row. Is that possible?
<a href="/signup?name=A2&email=B2">Go</a>
So the A2 and B2 would be contents of their respective cells. Tried out a few things but kept getting errors.
I have a function that locates a table on a webpage and pulls the html code into one cell in a worksheet. Basically we can call this one cell a text file. I need to parse through this text file (cell A1) to create a table. This text file only has info for 1 table, the table always has 12 columns, the rows are variable. I would like it to then write back this parsed text file back into excel as a table, say starting in cell A2 on the same worksheet.
I've go a shared Workbook, which will be distributed among several users and stored in different places. The workbook uses the following
Sub savemeas() Worksheets("data").Visible = True Sheets("data").Copy Application.DisplayAlerts = False ActiveWorkbook. SaveAs Filename:="d:" & Range("a1").Value, _ FileFormat:=xlText, CreateBackup:=False Application.DisplayAlerts = True ActiveWorkbook.Close SaveChanges:=True End Sub
to save the sheet "data" as a text file with a name based on the value of cell a1. All I need is to modify the code so that the target path would not be
but be the same as the source Workbook's - so that I wouldn't have to modify the code for each user separatly, because the sheet would alwayas be saved in the same folder as the current path of the source workbook.
I am trying to extract the data values from the references Bundesbank page and get them into a worksheet so I can manipulate from there. What I have is below.
I currently have a macro to import user selected .Dat files into a new workbook, each on its own worksheet. My problem comes in trying to save this new workbook in the same folder as the imported .Dat files. I was thinking there should be a way to gather the file path from the imported files and use that in the Save As command.
Does anyone have a VB macro that will copy information from a cell (this will be variable based on criteria) and paste it into the middle of another cell that contains HTML code?
The criteria for the copy/insert/paste is that the information in the cell that is to be copy/inserted must match up with the correct number (part number).
I hope this makes sense. I have attached an example spreadsheet. (Pictures are worth 1000 words. ) Hope someone can help. I checked this site and couldn't find anything that was solved that matched the specifics.
I am attempting to navigate to a webpage using IE. I have been successful at getting to the appropriate webpage.
However, I would like to open a link within the webpage in the browser in another window(Which is an image). Copy the image then paste it back into excel. I have been successful at opening the webpage using a Userform.
Code: Sub Anthro() Application.ScreenUpdating = False Set ie = CreateObject("InternetExplorer.Application") With ie .Visible = True
[Code] .......
The user input number for example:
If the user inputs the number 25423310 into the txtbox then it navigates to a certain webpage.
On this webpage and all other webpages where different #'s are used are very similar. The number (25423310) is always used to identify an image. However it has more characters. For example the image is always on line 30 of the HTML code. On this example the HTML code lists the image as:
The number used in the txtbox to naviagete to the URL Ex: 25423310) is always within line 30 of code in HTML. Is it possible to run a query or parse this line of code and direct ie to open this image in a new window then copy and paste it based on the criteria of the user input? Ex. 25423310?
Code: Sub PropInfo() Dim appIE As SHDocVw.InternetExplorer Set appIE = New SHDocVw.InternetExplorer Dim varTables, varTable
Each of the worksheets in my model use A1 as a control cell for any errors and inconsistencies. My aim is to disable save and close commands in case A1 is not equal to 0 in any of the worksheets.
The code I currently use for that purpose is as follows.