HTML link and extracting Javascript content?

London_Calling

Active Member
Joined
Feb 27, 2007
Messages
256
Morning all,

I used the usual 'Get external data' route to import to a spreadsheet a series of HTML links, but what I really want is to extract the Javascript from those links. It's curious because I can extract the Javascript by importing the HTML to Word, then copying it, and pasting back to Excel using Paste Special > Unicode/Text.

In vba, I get to PasteSpecial, but can't see a method that can help . . .

I guess the simpler question would be, in Excel or vba, can I Paste Special > Unicode/Text, or extract the Javascript by other means?

Cheers.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
In VBA:

ActiveSheet.PasteSpecial Format:="Unicode Text", Link:=False, DisplayAsIcon:=False

You need to select the target cell first. Note that the PasteSpecial method of the Worksheet object is different from the PasteSpecial method of the Range object.
 
Upvote 0
Hi Andrew,

So I can get to the Unicode Text method via the Worksheet object - thank you for that!

I can't quite get my head around selecting the "target cell" (is that the copy cell or the paste cell?) and then ActiveSheet.PasteSpecial - a cell and then a sheet . . . I'm obviously misunderstanding your advice.

Thanks for the help.
 
Upvote 0
The Worksheet's PasteSpecial method pastes into the active cell. So you need to select it first (unless you don't care where the data is pasted).
 
Upvote 0
Ok, officially I'm having a thick morning . . . and I'm going nuts; could you please point out where I'm going wrong!!

Code:
Range("A6").Select
Selection.Copy
ActiveCell.Offset(0, 5).Select
ActiveSheet.PasteSpecial Format:="Unicode Text", Link:=False, DisplayAsIcon:=False
 
Upvote 0
You use the Worksheet's PasteSpecial method when you are pasting from an external application (eg Word, which you mentioned in your first post). You use the Range's PasteSpecial method when pasting within Excel.
 
Upvote 0
Sure, I did it in Word to see if it was possible. I guess you're saying it isn't possible to do it within Excel (i.e. Range > PasteSpecial > Unicode Text).

Thanks very much for you time, Andrew - have a good one!
 
Upvote 0
Hi, I'm just re-stating this in case any of the evening crew have a suggestion. I import web page HTML links into Excel and I'd like to extract the javascript contained within the link, like this:

HTML link contains:
Code:
 javascript:showProfile('person','59472')

I'd like to paste that javascript in an offset cell.

It doesn't seem possible to extract the code within Excel as (so far) I've only been able to do it from Word using PasteSpecial > Unicode Text, and you can't do that within Excel.


Just looking for any bright ideas, really. Tricky one, I suspect!

Cheers.
 
Upvote 0

Forum statistics

Threads
1,214,960
Messages
6,122,479
Members
449,088
Latest member
Melvetica

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top