Word 宏状态栏消息消失



我有一个脚本,可以在随机时间发送邮件。 现在我希望它在状态栏中指示当前状态,例如"已发送 73 封邮件中的 3 封"。

  1. 我设法让它输出当前数字,如何输出总数?
  2. 状态栏不再显示我的信息,一旦我单击 Word,它就会消失并且不显示。然后,它仅显示当前的字数。
' Merges one record at a time to email with a pre-defined delay between messages.
' Sourced from: https://www.msofficeforums.com/mail-merge/38282-email-merge-delay.html
Application.ScreenUpdating = False
Application.DisplayStatusBar = True
Dim i As Long
With ActiveDocument
For i = 1 To .MailMerge.DataSource.RecordCount
aktuell = i
With .MailMerge
.Destination = wdSendToEmail
.MailSubject = "TECOSIM wünscht frohe Weihnachten!"
.MailFormat = wdMailFormatHTML
.MailAddressFieldName = "EMAIL"
.SuppressBlankLines = True
With .DataSource
.FirstRecord = i
.LastRecord = i
.ActiveRecord = i
End With
.Execute Pause:=False
End With
Dim PauseDelay As Long
PauseDelay = Int((480 - 300 + 1) * Rnd + 300) '
Application.StatusBar = "Der Versand wird aktuell durchgeführt..." & aktuell & " gesendet."
Call Pause(PauseDelay) ' Calls Pause with the random interval
Next i
End With
Application.ScreenUpdating = True
End Sub

Public Function Pause(Delay As Long)
Dim Start As Long
Start = Timer
If Start + Delay > 86399 Then
Start = 0: Delay = (Start + Delay) Mod 86400
Do While Timer > 1
DoEvents ' Yield to other processes.
Loop
End If
Do While Timer < Start + Delay
DoEvents ' Yield to other processes.
Loop
End Function

I hope you can help me.

尝试:

Dim i As Long, j As Long
With ActiveDocument
j = .MailMerge.DataSource.RecordCount
For i = 1 To j
...
Application.StatusBar = "Senden läuft ... " & i & " von " & j & " gesendet."

最新更新