Word宏状态栏消息消失

问题描述 投票:0回答:1

我有一个脚本,可以在任意时间发送邮件。现在我要它在状态栏中指示当前状态,例如“已发送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.
vba ms-word
1个回答
0
投票

尝试:

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."
© www.soinside.com 2019 - 2024. All rights reserved.