Hallo Steffi,
probier es doch mal so:
Sub cmbOK_Click()
Dim t1, t2, t3, idx
t1 = Array("Funktionskosten ", "Erstelldatum: ", "Bearbeiter/Abteilung: ")
t2 = Array("CenterHeader", "LeftFooter", "LeftFooter")
t3 = Array(TextBox1.Value, TextBox2.Value, TextBox3.Value)
t4 = Array("", Chr(10), "")
Application.PrintCommunication = False
For idx = LBound(t1) To UBound(t1)
If t3(idx) = "" Then t3(idx) = GetText(t1(idx), t2(idx), t4(idx))
Next idx
With ActiveSheet.PageSetup
.CenterHeader = "&""Calibri,Fett""&16Funktionskosten " & t3(0)
.LeftFooter = "&""Calibri,Fett""&9Erstelldatum: " & t3(1) & Chr(10) & "&9Bearbeiter/Abteilung: " & t3(2)
End With
Application.PrintCommunication = True
Unload usf_Befüllen
End Sub
Public Function GetText(find, prop, limit) As Variant
Dim txt, pos1, pos2
txt = CallByName(ActiveSheet.PageSetup, prop, VbGet)
pos1 = InStr(txt, find) + Len(find)
If limit = "" Then
pos2 = Len(txt)
Else
pos2 = InStr(txt, limit)
End If
GetText = Mid(txt, pos1, pos2 - pos1)
End Function
|