Automatische aktuelle Datumsangabe
#23
Hallo Siggi,

Mit einer kleinen Ergänzung sollte es möglich sein, alle Seiten zu bearbeiten:
Code:
Sub UpdateDateAndExport3()
   Dim PDFEinst As PDFVBASettings
   Dim currentDate As String, PDFName As String, FormatString As String
   Dim x As Shape
   Dim S As Page
   Dim xR  As ShapeRange, xRall As New ShapeRange
   Dim ds() As String
   
   If Documents.Count < 1 Then Exit Sub 'Abbrechen falls kein Dokument vorhanden ist
   Set PDFEinst = ActiveDocument.PDFSettings
   
   ' Aktuelles Datum im Format "DD.MM.YY"
  currentDate = Format(Date, "DD.MM.YY")
 
  For Each S In ActiveDocument.Pages 'Auf allen Seiten suchen
       Set xR = S.Shapes.FindShapes(Query:="@com.name.StartsWith('DatumHeute')")
       xRall.AddRange xR
  Next
 
  For Each x In xRall
      ' Überprüfen, ob die Form den Namen "DatumHeute" hat
      If x.Name = "DatumHeute" Then
          x.Text.Story = currentDate
          ElseIf Left(x.Name, 10) = "DatumHeute" Then ' Überprüfen, ob der Name der Form mit "DatumHeute" beginnt
          ds = Split(x.Name, "(")
          FormatString = Left(ds(1), Len(ds(1)) - 1)
          x.Text.Story = Format$(Date, FormatString)
          FormatString = ""
      End If
  Next

  ' Dokument speichern
  ActiveDocument.Save

  PDFName = DateiDialog
  If PDFName = "" Then Exit Sub 'Abbrechen falls kein Name übergeben wurde
  If Not PDFEinst.ShowDialog Then Exit Sub 'Abbrechen falls Abbrechen gewählt wurde
  ActiveDocument.PublishToPDF PDFName

End Sub

Falls es mit Deiner Version nicht klappt, melde Dich noch einmal.
Es könnte nützlich sein, Deine Version in der Signatur zu erwähnen.

Gruß

Koter
Zitieren



Nachrichten in diesem Thema
RE: Automatische aktuelle Datumsangabe - von koter - 13.09.2024, 12:55
Automatische aktuelle Datumsangabe - von koter - 20.01.2013, 15:05
Automatische aktuelle Datumsangabe - von koter - 20.01.2013, 15:32
Automatische aktuelle Datumsangabe - von koter - 20.01.2013, 17:44
Automatische aktuelle Datumsangabe - von koter - 20.01.2013, 17:55
Automatische aktuelle Datumsangabe - von koter - 20.01.2013, 20:07
Automatische aktuelle Datumsangabe - von norre - 20.01.2013, 20:13
Automatische aktuelle Datumsangabe - von koter - 20.01.2013, 20:56
Automatische aktuelle Datumsangabe - von Suc - 20.01.2013, 22:52
Automatische aktuelle Datumsangabe - von Blacky - 20.01.2013, 23:42
Automatische aktuelle Datumsangabe - von norre - 21.01.2013, 09:45

Möglicherweise verwandte Themen...
Thema Verfasser Antworten Ansichten Letzter Beitrag
  Aktuelle Seite drucken als Standard einstellen Karthagos 5 1.572 17.12.2021, 14:38
Letzter Beitrag: miss_marple
  Automatische Kleinschreibung beenden eckeneckepen 5 987 29.10.2020, 08:35
Letzter Beitrag: Litschi
  Automatische Farbfüllung? Max 2 1.029 07.08.2016, 11:59
Letzter Beitrag: Max
  VBA Script erstellen - automatische Tabelle erstellen phs 1 2.872 29.04.2014, 20:00
Letzter Beitrag: koter
  Automatische Hyperlink Generierung von e-mail Adressen ausschalten rainer 2 1.812 23.05.2013, 18:14
Letzter Beitrag: rainer
  Seitenhintergrund nur für die aktuelle Kutschka 2 1.160 13.03.2007, 16:19
Letzter Beitrag: Kutschka