excel - 如果窗口被锁定,宏不会循环
问题描述
我有这个从互联网页面抓取数据的宏:
Sub SA()
Application.ScreenUpdating = False
'# Ouvre une fenetre Internet Explorer
Set ie = New InternetExplorerMedium
With ie
.navigate "http://pfrwtekref/websail/"
While .readyState <> 4: DoEvents: Wend
Application.Wait Now + TimeValue("0:00:01")
.Visible = False
Set frm = .document.getElementById("Form1")
'# Connection à Sail
With frm
.elements("txtLogin").Value = private
.elements("txtPwd").Value = private
.elements("Button1").Click
End With
Application.Wait Now + TimeValue("0:00:01")
While .readyState <> 4: DoEvents: Wend
.navigate "http://pfrwtekref/websail/frmSuiviActivite.aspx"
Application.Wait Now + TimeValue("0:00:01")
'# Recupere les données dans deux cellules données
Set frm = .document.getElementById("Form1")
Application.Wait Now + TimeValue("0:00:01")
'Se place sur la ligne apres la derniere ligne du tableau
lign = Cells(Rows.Count, 1).End(xlUp).Row
lignL = lign + 1
With frm
'Recupere les données dans la feuille cockpit et les inscrit dans le tableau de suivi d'activité (SA)
WSSA.Cells(lignL, 1) = Date
WSSA.Cells(lignL, 2) = Time
WSSA.Cells(lignL, "C") = .all(11).innerText
WSSA.Cells(lignL, "F") = .all(12).innerText
WSSA.Cells(lignL, "D") = .all(37).innerText
WSSA.Cells(lignL, "G") = .all(38).innerText
WSSA.Cells(lignL, "E") = .all(37).innerText
WSSA.Cells(lignL, "H") = .all(38).innerText
End With
'# Ferme la fenêtre Internet
.Quit
End With
'Supprime tout les "/" qui auraient pu se glisser dans la ligne
WSSA.Range("C" & lignL & ":D" & lignL).Replace What:="/*", Replacement:=""
WSSA.Range("F" & lignL & ":G" & lignL).Replace What:="/*", Replacement:=""
WSSA.Range("E" & lignL).Replace What:="*/", Replacement:=""
WSSA.Range("H" & lignL).Replace What:="*/", Replacement:=""
Application.OnTime Now + TimeValue("00:15:00"), "SA.SA"
Application.ScreenUpdating = True
End If
End Sub
当我让它在后台运行时效果很好,但如果我的 Windows 会话被锁定,我的宏不再循环(每 15 分钟)。你知道是否有办法解决这个问题?
谢谢,祝你有美好的一天!
解决方案
推荐阅读
- node.js - 如何将 req.user 从 express-validator 传递到下一个中间件
- django - 如何使用 Django 和 OAuth 2 从我的 G-Suite 帐户发送电子邮件?
- swift - 如何从 Walk Run Stride 蓝牙传感器的特征数据中识别值
- windows - 通过控制台更改 Windows 上的屏幕亮度
- c# - 当我的角色移动到不同的方向时,我的 Unity 2D 播放器控制器脚本不会让我的角色翻转
- c# - 查找与组策略对象对应的注册表项
- java - 如何运行 java jar 文件并将输出存储在 shell 脚本变量中
- react-native - 反应原生:模态不显示
- c++ - 带参数的 C++ Meyer 单例
- php - 如何在 PHP-Parser 中获取全局变量的索引