Form: automatische datum & als een regel leeg is

  • Onderwerp starter Onderwerp starter Ytos
  • Startdatum Startdatum
Status
Niet open voor verdere reacties.

Ytos

Gebruiker
Lid geworden
6 jun 2001
Berichten
318
Ik heb in Word een formulier gemaakt, dat ik gebruik voor m'n brieven. Teksten in invoervelden die in het formulier worden ingevoerd, worden bij verschillende bookmarks gezet.

Ik heb een 2-tal vragen over de invoervelden:

1. Ik heb bij adresgegevens 5 invoervelden. De 2e is "t.a.v.", maar die wordt niet altijd gevuld. Ik heb 1 bookmark voor het hele adres; na de 1e drie regels komt er een enter. Dus:

Naam (enter)
t.a.v. (enter)
Adres (enter)
PC Woonplaats

Als het veld "t.a.v." echter leeg is, moet de enter die daar normaalgesproken achter komt niet gegeven worden. Een if-then routine dus. Maar hoe maak ik die in het vba-form, zodat ik het volgende krijg:

Naam (enter)
Adres (enter)
PC Woonplaats


2. Ik heb een veld datum. Ik zou graag zien dat de datum daar al ingevuld wordt, maar dat ik die wel nog zelf kan veranderen. De datum als veld in het sjabloon invoegen en dan automatisch laten bijwerken vind ik niets, want dan veranderd de datum ook als je het document later weer opent.
Hoe kan ik dus alvast een veld vullen, in dit geval met de datum?

Heel hartelijk dank voor de moeite.

Ik zet hieronder overigens de code neer die ik tot nu toe heb:

Private Sub CommandButton1_Click()
Selection.GoTo what:=wdGoToBookmark, Name:="adres"
Selection.TypeText TextBox1.Text
Selection.TypeParagraph
Selection.TypeText TextBox2.Text
Selection.TypeParagraph
Selection.TypeText TextBox3.Text
Selection.TypeParagraph
Selection.TypeText TextBox4.Text
Selection.TypeText Text:=" "
Selection.TypeText TextBox5.Text
Selection.GoTo what:=wdGoToBookmark, Name:="datum"
Selection.TypeText TextBox6.Text
Selection.GoTo what:=wdGoToBookmark, Name:="betreft"
Selection.TypeText TextBox7.Text
Selection.GoTo what:=wdGoToBookmark, Name:="kenmerk"
Selection.TypeText TextBox8.Text
Selection.GoTo what:=wdGoToBookmark, Name:="uw_kenmerk"
Selection.TypeText TextBox9.Text
Selection.GoTo what:=wdGoToBookmark, Name:="aanhef"
Selection.TypeText TextBox10.Text
Selection.GoTo what:=wdGoToBookmark, Name:="ondertekening"
Selection.TypeText TextBox11.Text
Selection.GoTo what:=wdGoToBookmark, Name:="bijlage"
Selection.TypeText TextBox12.Text
UserForm1.hide
End Sub
 
ik gewoon vb weet ik wel hoe ik die vragen moet op lossen maar werk dat ook het zelfde in word
meld mij anders even aan op msn
aart@aart.nl
 
Heb inmiddels zelf een oplossing gevonden voor het probleem van de regels overslaan. Heb het in onderstaande code opgelost:

Private Sub CommandButton1_Click()
Selection.GoTo what:=wdGoToBookmark, Name:="adres"
Selection.TypeText TextBox1.Text
If TextBox2 <> "" Then Selection.TypeParagraph
If TextBox2 <> "" Then Selection.TypeText TextBox2.Text
Selection.TypeParagraph
Selection.TypeText TextBox3.Text
Selection.TypeParagraph
Selection.TypeText TextBox4.Text
Selection.TypeText Text:=" "
Selection.TypeText TextBox5.Text
Selection.GoTo what:=wdGoToBookmark, Name:="datum"
Selection.TypeText TextBox6.Text
Selection.GoTo what:=wdGoToBookmark, Name:="betreft"
Selection.TypeText TextBox7.Text
Selection.GoTo what:=wdGoToBookmark, Name:="kenmerk"
Selection.TypeText TextBox8.Text
Selection.GoTo what:=wdGoToBookmark, Name:="uw_kenmerk"
Selection.TypeText TextBox9.Text
Selection.GoTo what:=wdGoToBookmark, Name:="aanhef"
Selection.TypeText TextBox10.Text
Selection.GoTo what:=wdGoToBookmark, Name:="ondertekening"
Selection.TypeText TextBox11.Text
Selection.GoTo what:=wdGoToBookmark, Name:="bijlage"
Selection.TypeText TextBox12.Text
UserForm1.hide
End Sub

Zal wel niet zo netjes zijn, maar het werk naar behoren.

Nu nog de datum vast in een cel, zo dat 'ie wel te wijzigen is. Iemand een idee???
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan