Excel中怎么让超链接点击进入WebBrowser控件而不是IE? 200
怎么点击超链接进入的是WebBrowser控件而不是IE?由于工作中经常要在IE和excel间切换,如果点击超链接后在excel内部,就不用再切换页面了。哪位大侠给些建议...
怎么点击超链接进入的是WebBrowser控件而不是IE?由于工作中经常要在IE和excel间切换,如果点击超链接后在excel内部,就不用再切换页面了。哪位大侠给些建议或者提示?
设置事件:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Hyperlinks.Count > 0 And Target.Count = 1 Then
WebBrowser1.Navigate Target.Hyperlinks.Item(1).Address
End If
End Sub
但刷新的同时IE仍然要打开 展开
设置事件:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Hyperlinks.Count > 0 And Target.Count = 1 Then
WebBrowser1.Navigate Target.Hyperlinks.Item(1).Address
End If
End Sub
但刷新的同时IE仍然要打开 展开
3个回答
展开全部
继承JEditorPane实现超连接监听事件HyperlinkListener
class HTMLPane extends JEditorPane implements HyperlinkListener
{
final JEditorPane paneRefefernce;
public HTMLPane(String content) throws IOException {
paneRefefernce = this;
super(content);
addHyperlinkListener(this);
paneRefefernce = this;
setEditable(false);
}
public void hyperlinkUpdate(HyperlinkEvent e) {
try {
if ( e.getEventType() == HyperlinkEvent.EventType.ACTIVATED
)
paneRefefernce.setPage(e.getURL());
} catch (Exception ex) {
ex.printStackTrace(System.err);
}
}
}
调用:
StringBuffer sb = new StringBuffer();
DataInputStream istr =
new DataInputStream(
new BufferedInputStream(
new FileInputStream("1.txt")));
BufferedReader reader = new BufferedReader(new InputStreamReader(istr));
String line;
while ((line = reader.readLine()) != null) {
sb.append(line);
}
display.setText(sb.toString());
display.setContentType("text/html");
class HTMLPane extends JEditorPane implements HyperlinkListener
{
final JEditorPane paneRefefernce;
public HTMLPane(String content) throws IOException {
paneRefefernce = this;
super(content);
addHyperlinkListener(this);
paneRefefernce = this;
setEditable(false);
}
public void hyperlinkUpdate(HyperlinkEvent e) {
try {
if ( e.getEventType() == HyperlinkEvent.EventType.ACTIVATED
)
paneRefefernce.setPage(e.getURL());
} catch (Exception ex) {
ex.printStackTrace(System.err);
}
}
}
调用:
StringBuffer sb = new StringBuffer();
DataInputStream istr =
new DataInputStream(
new BufferedInputStream(
new FileInputStream("1.txt")));
BufferedReader reader = new BufferedReader(new InputStreamReader(istr));
String line;
while ((line = reader.readLine()) != null) {
sb.append(line);
}
display.setText(sb.toString());
display.setContentType("text/html");
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询