gpt4 book ai didi

vba - 如何使用 Excel 在打开的 Chrome 选项卡中打开新 URL,而无需打开新选项卡

转载 作者:行者123 更新时间:2023-12-02 23:01:59 25 4
gpt4 key购买 nike

我的 Excel 电子表格中有两个按钮。当我点击button1时,Chrome会打开一个新选项卡,但是当我点击button2时,Chrome会打开另一个选项卡。

我想要的是,当我单击button2时,使用button1打开的Chrome选项卡将通过刷新第一个选项卡中的URL来访问button2的URL,而不是创建新选项卡。谢谢!

Private Sub Button1_Click()
chromePath = """C:\Program Files\Google\Chrome\Application\chrome.exe"""
Shell (chromePath & " -url http:abc.com")
End Sub

Private Sub CommandButton2_Click()
chromePath = """C:\Program Files\Google\Chrome\Application\chrome.exe"""
Shell (chromePath & " -url http:def.com")
End Sub

最佳答案

查看Selenium VBA 。也许使用 switchTo() 方法可以将 Selenium 的焦点设置到打开的 Chrome 窗口,然后可以像往常一样使用其他 Selenium 方法实现自动化。

关于vba - 如何使用 Excel 在打开的 Chrome 选项卡中打开新 URL,而无需打开新选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20731451/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com