excel - 如何将光标聚焦到带有预插入斜杠(_ _/_ _/_ _ _ _)的文本框的起始位置,用于 VBA 中的日期字段
问题描述
我有一个文本框,其中已经插入了斜杠,例如 (_ / / _ _ _) 。我遇到的问题是光标被放置在文本框的末尾而不是日期,因为日期是从文本框的起始位置输入的。我传递的值采用这种格式(“mmddyyyy”)。
Dim BirthDate As String
BirthDate = Format(Range(cell).Value, "mmddyyyy")
bot.FindElementByXPath("//*[@id='DateOfBirth']").SendKeys BirthDate
' when I run this line the cursor goes to the last position in the textbox.
如何将光标的焦点设置到起始位置。我编写的脚本是使用 selenium webdriver、chromedriver 在 VBA 自动化中编写的。
解决方案
我假设你已经声明了类似的东西
Dim bot As New Selenium.ChromeDriver
所以也在那里声明
Dim Keys As New Selenium.Keys
你可以使用类似的东西
Dim BirthDate As String
BirthDate = Format(Range(cell).Value, "mmddyyyy")
bot.FindElementByXPath("//*[@id='DateOfBirth']").SendKeys Keys.Home
bot.FindElementByXPath("//*[@id='DateOfBirth']").SendKeys BirthDate
推荐阅读
- javascript - 为什么 Quill 过滤其内容?
- sql - 从循环中选择具有相似名称但添加了增量编号的表列表
- nvidia - 尝试使用 nvidia 光线跟踪扩展程序跟踪三角形时得到一个立方体
- shell - shell中的大制表符分隔文件操作
- html - 如何将两个引导 col div 与左侧的第三个 col div 对齐?
- json - 如何从 JSON 文件中获取特定字段?
- mainframe - 有没有办法将数组传递给外部 REXX 程序?
- android - Android:即使迁移到 Android X,也无法在我的设计中使用 TabLayout
- python - Tkinter:使用 grid() 插入数据?
- python-3.x - 如何在 concat/merge/join 之后的同一天的所有 5 分钟日期时间行中复制每日日期时间值?