Getting Clipboard Data (HTML Web Source) To Paste Into Specified Cell
Feb 7, 2013
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 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.
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 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 copy cells from one worksheet to another, but have the cells that I paste link to the original document. Is there an easy way to do this?
So if I'm pasting from worksheet A into worksheet B, I would like worksheet B to link to worksheet A.
I Want users to be able to copy a reference number from a an external program into excel, this works well for single cells but the cell I want them to be able to paste the information into is a merged cell and keep getting the "Data on the clipboard is not the same size and shape blah blah error". What I can do to get this information to paste? Is there some VBA that can kinda trick the cell to believe its single or when pasting it unmerges and then remerges again?
I need a snipit of code that will paste the clipboard when the OK button on a message box (vbOkOnly) is pushed. I have in the past was able to make it stop if "Cancel" was selected, but one button seems to be harder for me.
I am using the following code in a template I have created for my department. I am copying a formula from the 7th row of the specified columns and want to copy and paste the row down to the "last row" which I have specified from an input box. I am trying to do this without using the clipboard, because some files are 50,000 lines or more and I want to speed this process up.
In the code where I have say Sheet4.Range("A8:I140000") I would like to use last row somehow like Sheet4.Range("A8:Lastrow")
If the user clicks the button to do the paste special macro twice - the second time they get an error (I am assuming that the clipboard has been wiped clean and they need to go back and copy the data again). The specific error message is: "Run-time error '1004': PasteSpecial method of Range class failed".
What I would like to do is add code to the pastespecial macro that looks to see if there is something to paste - if not, I want to give my own message and not the default one.
I created a macro that will do a subtotal and copy the value then undo the subtotal and delete all the values(i dont need the actual raw data, just need the subtotal). i noticed when i do a copy, i have to paste from the office clipboard. is there a macro i can use to paste from the first item on the list?
I'm doing a data/filter/advanced filter/show all/unique records to get rid of any duplicate rows. I tried creating a macro and but the macro recorder doesn't know that I want to do NOT a regular paste, but a paste from the most recent entry from the Office Clipboard. Is there a formula and/or macro that will allow me to do this?
I've recently switched from office 2003 to office 2007.
In excel 2003 I was able to paste html into excel for easy editing. In excel 2007, when I paste the html I see auto-formatted web page objects. How can I disable this and get just straight text?
I tried formatting the cells to be plain text and then pasting.
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'm using excel 2003 and was wondering if I could insert html around the cell data in a faster way than cutting and pasting it. Here is an example of a column and what I would like to do.
aaaa bbbb cccc dddd
Now I would like every cell to have HTML around it to be easily posted on a website. I would like the cells to now look like this.
I have a cell in which I have the following data (for example):
<a href="http://www.trucks.com">Ford Trucks</a>
I need to export the sheet as a tab delimited txt file for import into another program. When excel saves the file as .txt, it add extra data so that the cell is represented as:
Note the set of two additional inverted commas. This extra data interferes with the parsing of the data in the other program. I've tried formatting the cells to "general" and "text", however, it does not seem to affect the txt output.
I have a report that was created for 2005 that contains two worksheets: a "source data" worksheet and a " pivot table" worksheet. I cleared out the 2005 data in the "source data" worksheet and replaced it with 2006 data...after this I refreshed the Pivot Table and everything seemed fine. When looking at the file size I noticed that it was almost twice its original size....upon further investigation I found that the Pivot Table was internally holding onto the old source data (the "Show" functionality of the rows/columns in the table lists the 2005 row/column headers as well as the 2006 headers....even though no data from 2005 is shown in the Pivot Table).
Does anyone know how to purge the old data from the internal Pivot Table memory?
I hope this is enough information....let me know if you need more.
I want the same affect as copy a table and pasting into the email. So i guess i need to copy a range and save as html in a string. It seems like it would be simple since its just copy and paste into the email, but i've been unable to find anyting on it.
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
I have a bar chart that was made from table 1 which has the value in it. I have another table, table 2 that has the name corresponding to the value in table 1. I want to color data points in a bar chart with a different color for each name I have in table 2. I also want to give a data label in the data points with the value I have in table 2 instead of the original data label from table 1. Is it possible to do it?
In cell A1 I have a forumlar which equals 'A2:F1465' which is the range of my data, how can I get a pivot table to use this for it's values as when I do it normally it asks me to manually select the range as above?
I have 4 sheets. In each sheet, I have a column of data for every hour of every day of one year.
In the 1st worksheet, I want to make a chart using :
- for Y values : the average of the data for each day - for X values: the day
In the 3 other worksheets, - for Y values : the data for each hour - for X values: the hour
To make it more simple, I will first build in the "D" column the data of the average data for each day (so, every 24 columns)
Here is my
Dim lNbSheet As Long ' sheet number Dim rSheetData As Range ' what will be my Y values Dim rSheetTime As Range ' what will be my X values Dim sSheetName As String ' current sheet
For lNbSheet = 1 To 4
'selection of the Y values Sheets(lNbSheet).Select sSheetName = ActiveSheet.Name
I get the error "methode SeriesCollectiosn of Object _chart failed;
Also, if you have an idea that could make me avoid writing all the new average-for-the-day data in column D (using it directly),
I have a pivot table whose data source is located on a shared network drive. Each day a new data source is uploaded and the only thing that changes is the date in the filename (ie. DataSource080813.xlsx). I am trying to find a way to set the data source to update with todays date automatically each day so that when you open the workbook it is always current days data. I have a cell (B2) with a formula in it that gives me the file location of todays file (ie. X:TeamFolderFile1DataSource080813.xlsx, where the date is derived using the TODAY() function. Is there a way to set the pivot table data source to cell B2 and have it use the text from B2 as the file location?
I'm trying to implement a very simple macro to paste a set of cells - already copied to the clipboard from a CSV file - into a worksheet.
Basically, all I need it to do is to allow the user to open that other CSV file, hit CTRL+A and CTRL+C, then go to the relevant sheet in my workbook and run the macro, which should simply paste the copied data into that sheet (starting at cell A30).
Here's what I have so far - I keep getting an error when the macro reaches the ActiveSheet.Paste command.
VB: Sub UpdateData() ' ' UpdateData Macro ' Dim strSheetName As String
I am trying to write a macro to paste the data that has been copied onto the clipboard into my worksheet. However I want to paste it in different ways depending on what data is there.
This is what I have so far:
Sub ImportTissue() Sheets("Tissue").Select If "dimensions of clipboard data are 5 cells by 5 cells" Then