View Single Post
 
Old 01-26-2010, 05:49 AM
Vivi Vivi is offline Windows XP Office 2007
Novice
 
Join Date: Jan 2010
Posts: 2
Vivi is on a distinguished road
Default Array into ComboBox + Macro-Text into ActiveDocument

Hello,
I've got a problem while coding with VBA in Word 2007. So, I managed to build a userform and soem macros. Some of them work, left does not.

I have some textboxes (for a letter) including the surnames of yourself and the addressee, the prename of yourself and a combobox where you can switch (will switch hopefully with your help ) between male and female (Dear Sir/Madame [surname]).

What works:
Surnames and Prenames saving after input of the user, but no writing into the document with textmarks.
Autopen the userform when opening a new document template.

What does not work:
Described on top - the combobox does not work, I cannot include "Sir" or "Madame" into the box, tried it with AddItem and Arrays... Some loops and so on.
And the other main point - Writing the finale issues like pre- and surname into the document template (Dear ... ..., [text] Yours faithfully, ...).

Code for Userform:
Code:
Sub AutoOpen() 'Tests with AddItem and so on
    gender.AddItem "Frau"
    gender.AddItem "Herr"
End Sub

Private Sub gender_Click()
    gender.DropDown
End Sub

Private Sub format_Initialize()
    gender.AddItem "Frau"
    gender.AddItem "Herr"
End Sub

Private Sub btnabbrechen_Click() 
    Unload Me ' Close
End Sub

Private Sub btnok_Click() 'OK 'Writing into the document

    ThisDocument.Activate
    If gender = "Frau" Then
    genda = "geehrte Frau"
    Else
    genda = "geehrter Herr"
    End If
    surname = empname
    absender = abprename & " " & abname
    Debug.Print genda, surname, absender
    
    Unload Me ' Box schließen
End Sub
Modul Code:
Code:
Sub AutoNew() 'autoopen 
    format.show
End Sub
So, I hope anyone can help me. I'm trying since yesterday and I didn't make it any better .

I'd appreciate you if you'd help me somehow. Any help's welcome!

Dear Vivi
Reply With Quote