VBA CODE for JAVASCRIPT CODE

ashish1110

New Member
Joined
Dec 12, 2012
Messages
1
Request to provide VBA code for below javascript code


htmlStr = htmlStr.replace(/[\n\r]+/g, '');
htmlStr = htmlStr.replace(/\"/g, "\"\"");
htmlStr = "\"" + htmlStr + "\"";
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Hi and welcome to the forum.

I don't know JavaScript, but the first two lines of your code looks like, "Find and Replace". Here is the vba REPLACE function; you will need to edit the highlighted parts.

Code:
   htmlStr = Replace(Expression:=htmlStr, _
                     Find:=[COLOR=#ff0000]FindString[/COLOR], _
                     Replace:=[COLOR=#ff0000]ReplacementString[/COLOR], _
                     Compare:=vbTextCompare)

NB: we can omit specifically referencing the REPLACE function's arguments. The above can be written as:

Code:
htmlStr = Replace(htmlStr, [COLOR=#ff0000]FindString[/COLOR], [COLOR=#ff0000]ReplacementString[/COLOR], vbTextCompare)

The third line looks like concatenating a backslash onto the htmlStr variable. In VBA the ampersand is the concatenation character.:
Code:
   htmlStr = "\" & htmlStr & "\"

Hope this helps,
Bertie
 
Upvote 0

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

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