Re: Document out of focus by CorvanderBliek
CorvanderBliek
Tue Feb 01 15:13:07 CST 2005
I'm creating new documents with the File New command, where the templates are
listed. In every template there's a AutoNew macro, which loads the UserForm:
Public Sub AutoNew()
Brief_Nederlands.Show
End Sub
The UserForm is activated with the following lines, in which personal
settings are loaded from C:\huisstijl_persoonlijk.txt:
Private Sub UserForm_Activate()
Me.Controls("Textbox8").Text = Format(Date, "d mmmm yyyy")
Me.Controls("Textbox3").Text = "t.a.v. "
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim fs, f, ts, s
Set fs = Application.FileSearch
With fs
.LookIn = "C:\"
.SearchSubFolders = False
.FileName = "huisstijl_persoonlijk.txt"
If .Execute() > 0 Then
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile("C:\huisstijl_persoonlijk.txt")
Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault)
s = ts.ReadLine
Me.Controls("Textbox11").Text = s
s = ts.ReadLine
Me.Controls("Textbox12").Text = s
s = ts.ReadLine
Me.Controls("Textbox13").Text = s
s = ts.ReadAll
s1 = InStr(s, "#")
Me.Controls("Textbox23").Text = Left(s, s1 - 1)
ts.Close
End If
End With
End Sub
Thanks for the effort.
"David" wrote:
> Search for the title of this message... 'Obtain the index number of
> the active document'
>
> They talk about document numbering within Word. When a new document
> gets loaded, the Document numbers change. If you are refering to the
> docs by using the Document(index) property (or Activedocument) you may
> be inadvertantly using the wrong index. Always better to name your
> documents an abritrary name so you can keep up with them.
> Document("SALES") for example.
>
> Are you, in fact, creating documents based on templates? You are not
> loading the template for editing???
>
>