V
VK
I know well JavaScript, Java, Perl, but I never programmed in VBA (just
never needed)
Now I need to insert my custom date (translated in German) into my
document (US version of Word). I did the best I remembered from my
QBasic youth, but I stoke in 3 problems:
1. I cannot collect the final string from strings (month, weekday) and
numbers (day, year)
I'm getting "Type Mismatch". Is there any toString casting in VBA, or
how does it work here?
2. I cannot understand how to assign this string to a bookmark. I used
GoTo dialog for now.
3. How to execute the script onLoad (on opening document). I remember
there was some autoexec() function, but I did not found any refs on it
in the help.
Please help me save my time and nerves!
Sub DateEN2DE()
Dim CurrentYear, GermanMonth, CurrentDay, GermanWeekDay As Variant
GermanMonth = Array("dummy", "Januar", "Februar", "März", "April",
"Mai", "Juni", "Juli", "August", "September", "Oktober", "November",
"Dezember")
GermanWeekDay = Array("dummy", "Sonntag", "Montag", "Dienstag",
"Mittwoch", "Donnerstag", "Freitag", "Samstag")
Selection.GoTo What:=wdGoToBookmark, Name:="MyDate"
Selection.Text = GermanWeekDay(WeekDay(Date)) + ", " +
GermanMonth(Month(Date)) + " "
' and this I cannot add because of "Type Mismatch"
' + Selection.Add Day(Date) + ", " + Year(Date)
End Sub
never needed)
Now I need to insert my custom date (translated in German) into my
document (US version of Word). I did the best I remembered from my
QBasic youth, but I stoke in 3 problems:
1. I cannot collect the final string from strings (month, weekday) and
numbers (day, year)
I'm getting "Type Mismatch". Is there any toString casting in VBA, or
how does it work here?
2. I cannot understand how to assign this string to a bookmark. I used
GoTo dialog for now.
3. How to execute the script onLoad (on opening document). I remember
there was some autoexec() function, but I did not found any refs on it
in the help.
Please help me save my time and nerves!
Sub DateEN2DE()
Dim CurrentYear, GermanMonth, CurrentDay, GermanWeekDay As Variant
GermanMonth = Array("dummy", "Januar", "Februar", "März", "April",
"Mai", "Juni", "Juli", "August", "September", "Oktober", "November",
"Dezember")
GermanWeekDay = Array("dummy", "Sonntag", "Montag", "Dienstag",
"Mittwoch", "Donnerstag", "Freitag", "Samstag")
Selection.GoTo What:=wdGoToBookmark, Name:="MyDate"
Selection.Text = GermanWeekDay(WeekDay(Date)) + ", " +
GermanMonth(Month(Date)) + " "
' and this I cannot add because of "Type Mismatch"
' + Selection.Add Day(Date) + ", " + Year(Date)
End Sub