Collapse column

Beiträge anzeigen

Diese Sektion erlaubt es dir alle Beiträge dieses Mitglieds zu sehen. Beachte, dass du nur solche Beiträge sehen kannst, zu denen du auch Zugriffsrechte hast.


Nachrichten - TheaAmanda

Seiten: [1]
1
Word / Antw:Office 2010: VBA: Inhaltsteuerelement (Word) in Textmarke einschließen
« am: September 13, 2012, 17:14:23 Nachmittag »
ich wäre wirklich über jede hilfe dankbar (bitte bitte bitte) - bei der range verlegung steh ich einfach aufm schlauch.

hier meine gehversuche:

Dim objCC As ContentControl
Dim oContentControl As Range
   
If TextBox1.Visible = True Then
     If ActiveDocument.Bookmarks.Exists("Feld") Then
            Set Marke1 = ActiveDocument.Bookmarks("Feld").Range
                Marke1.Text = TextBox1.Text & ":"
            ActiveDocument.Bookmarks.Add Name:="Feld", Range:=Marke1
    End If
    If ActiveDocument.Bookmarks.Exists("Feld2") Then
            Set Marke2 = ActiveDocument.Bookmarks("Feld2").Range
            Set objCC = Marke2.ContentControls.Add(wdContentControlText)
                objCC.SetPlaceholderText Text:="[" & TextBox1.Text & "]"
                objCC.Title = TextBox1.Text
            'Set Marke3 = objCC.Range
                'Set Marke2 = ActiveDocument.objCC(TextBox1.Text).Range
                'Muss noch überarbeitet werden!
                'Selection.Words.Last.Next.Select
                'ActiveDocument.Bookmarks("Feld2").Range.Characters.Last.Select
                'Selection.Collapse wdCollapseStart
                'Selection.TypeText "Material below is confidential."
            'Set oContentControl = SelectedContentControl
            'Set oContentControl = ActiveDocument.ContentControls(1).Range
            'Set oContentControl = objCC.Range
            'oContentControl.Collapse Direction:=wdCollapseStart

            ActiveDocument.Bookmarks.Add Name:="Feld2", Range:=Marke2
    End If
End If

2
Word / Office 2010: VBA: Inhaltsteuerelement (Word) in Textmarke einschließen
« am: September 10, 2012, 10:02:15 Vormittag »
Hallo,

ich hoffe dass mir jemand helfen kann. Ich habe eine Word Vorlage mit UserForm. In der UserForm wird ein Textfeld ggfls. (wenn CheckBox geklickt ist) angezeigt. Wenn das Textfeld angezeigt wird, dann soll im Dokument einmal links der Inhalt des Textfeldes "normal" stehen [soweit, so gut] und rechts daneben soll der Inhalt als Default-Text in einem Steuerelement gezeigt werden [klappt inzwischen auch].

Das Problem ist jetzt, dass wenn man die UserForm erneut ausführt, dann möchte ich dass das eingefügte durch das neue ersetzt wird. Das mache ich indem bei der ersten Ausführung sofort eine neue Textmarke erstellt wird und den eingefügten Text "umschließt". Das klappt mit normalen Text auch alles Prima, aber bei dem Steuerelement scheitere ich nun. Bei dem Steuerelement bleibt die Textmarke insich geschlossen (also Anfang = Ende) und steht vor dem Steuerelement.

Irgendwie müsste es doch möglich sein dass ich den Range des Steuerelements anspreche, oder? Vielen Dank.

Dim objCC As ContentControl

If TextBox1.Visible = True Then
     If ActiveDocument.Bookmarks.Exists("Feld") Then
            Set Marke1 = ActiveDocument.Bookmarks("Feld").Range
                Marke1.Text = TextBox1.Text & ":"
            ActiveDocument.Bookmarks.Add Name:="Feld", Range:=Marke1
    End If
    If ActiveDocument.Bookmarks.Exists("Feld2") Then
            Set Marke2 = ActiveDocument.Bookmarks("Feld2").Range
            Set objCC = Marke2.ContentControls.Add(wdContentControlText)
                objCC.SetPlaceholderText Text:="[" & TextBox1.Text & "]"
                objCC.Title = TextBox1.Text
            ActiveDocument.Bookmarks.Add Name:="Feld2", Range:=Marke2
    End If
End If

Seiten: [1]