Ask Question Forum:
Model Library:2025-02-08:A.I. model is online auto reply
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by duncanb7
at 2024-04-04 10:49:39
Point:500 Replies:4 POST_ID:828462USER_ID:11059
Topic:
Visual Basic Programming;;Microsoft Excel Spreadsheet Software
Generally, I like write VBA code in Excel xls file and then save as html file
and broswer the htm file in IE.
Now I get one Excel file saved as htm format because I will read it in IE windows.
and in the file sheet, and I add hyperlink in the one cells by VBA like following
small code
ActiveSheet.Cells(1,1).Select
ActiveSheet.Cells(1,1) = "Chart"
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="http://www.chart.com"
When I open the htm file in IE 7, and click the link that will be opened in the same windows
as the htm file window, and I go to notepad/edit the html file and see what happen at <a href> tag and found this
html code in my htm file as
<td class=xl155><a href="http://www.chart.com"
target="_parent ">Chart</a></td>
How can I change it to taget="_blank" from "_parent" in VBA? actually I could do it by replace function in vba
to seach _parent text in htm file and replace with __blank but I would like or prefer to see there is VBA code for this first
Any suggestion ?
Try the following three code, but all is not what I want
1-ThisWorkbook.FollowHyperlink Address:="http://www.chart.com", NewWindow:=True
2-ActiveWorkbook.FollowHyperlink Address:=Selection, NewWindow:=True
'3-Selection.Hyperlinks(1).Follow NewWindow:=True
Please advise, it should a VBA solution for that, and I have viewed this http://www.w3schools.com/tags/att_a_target.asp
target="_blanK" is opening hyperlink in a new window
Duncan
and broswer the htm file in IE.
Now I get one Excel file saved as htm format because I will read it in IE windows.
and in the file sheet, and I add hyperlink in the one cells by VBA like following
small code
ActiveSheet.Cells(1,1).Select
ActiveSheet.Cells(1,1) = "Chart"
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="http://www.chart.com"
When I open the htm file in IE 7, and click the link that will be opened in the same windows
as the htm file window, and I go to notepad/edit the html file and see what happen at <a href> tag and found this
html code in my htm file as
<td class=xl155><a href="http://www.chart.com"
target="_parent ">Chart</a></td>
How can I change it to taget="_blank" from "_parent" in VBA? actually I could do it by replace function in vba
to seach _parent text in htm file and replace with __blank but I would like or prefer to see there is VBA code for this first
Any suggestion ?
Try the following three code, but all is not what I want
1-ThisWorkbook.FollowHyperlink Address:="http://www.chart.com", NewWindow:=True
2-ActiveWorkbook.FollowHyperlink Address:=Selection, NewWindow:=True
'3-Selection.Hyperlinks(1).Follow NewWindow:=True
Please advise, it should a VBA solution for that, and I have viewed this http://www.w3schools.com/tags/att_a_target.asp
target="_blanK" is opening hyperlink in a new window
Duncan
Author: duncanb7 replied at 2024-04-11 13:26:39
Thanks for your reply
Expert: SiddharthRout replied at 2024-04-04 11:13:05
I am not aware if there is one.
Sid
Sid
Author: duncanb7 replied at 2024-04-04 11:11:25
Yes, it shoud work, but I mean is there any function like ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="http://www.chart.com" ,newwindow=true to see the cells' property
so we don't need to go the do loop
so we don't need to go the do loop
Accepted Solution
Expert: SiddharthRout replied at 2024-04-04 11:06:00
500 points EXCELLENT
Try this
UNTESTED
UNTESTED
Sub sample() Dim strTemp As String, FlName As String Dim ff As Integer '~~> Replace this with the html file path FlName = "C:AAA.htm" Open FlName For Input As #1 filesize = LOF(1) strTemp = Input(filesize, #1) Close #1 If InStr(1, strTemp, "_parent", vbTextCompare) Then Do While InStr(1, strTemp, "_parent", vbTextCompare) strTemp = Replace(strTemp, "_parent", "_blank") Loop End If ff = FreeFile() Open FlName For Output As #ff Print #ff, strTemp Close #ff MsgBox "Done"End Sub 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:
Sid