H
Hans Troost
Hello all,
For some testing during program development I want to
(programmatically) create a new document and add some or very much
(!!) text to it.
So I tried to use the (undocumented) =rand(x,y) function in my
VBA-program.
What I first did:
Sub Test()
Documents.Add
With ActiveDocument
Selection.TypeText Text:="=rand(3,5)"
End With
End Sub
What happened when running this macro?
1. New document created (fine thus far)
2. With text "=rand(3,5)" in it, in stead of 3 paragraphs with 5 times
"The quick....", so not good. However I can understand that it just
adds the string
3. Thus macro was finished and pressing the <enter>-key once changed
to document to the required result: but I dont want any interactive
interaction!!
So I tried the following:
Sub Test()
Documents.Add
With ActiveDocument
Selection.TypeText Text:="=rand(3,5)"
Selection.TypeParagraph
End With
End Sub
Same result: text =rand(3,5) in the document and same behaviour:
pressing <enter> changes it.
So another try:
Sub Test()
Documents.Add
With ActiveDocument
Selection.TypeText Text:="=rand(3,5)"
Call SendKeys("%{ENTER}")
End With
End Sub
This should do !! But no: now I enter with a document with the
following line:
=rand(3,5)=rand(3,5) (???...)
So my question is: how can I use the =rand(x,y) in a macro?
Regards,
Hans Troost
For some testing during program development I want to
(programmatically) create a new document and add some or very much
(!!) text to it.
So I tried to use the (undocumented) =rand(x,y) function in my
VBA-program.
What I first did:
Sub Test()
Documents.Add
With ActiveDocument
Selection.TypeText Text:="=rand(3,5)"
End With
End Sub
What happened when running this macro?
1. New document created (fine thus far)
2. With text "=rand(3,5)" in it, in stead of 3 paragraphs with 5 times
"The quick....", so not good. However I can understand that it just
adds the string
3. Thus macro was finished and pressing the <enter>-key once changed
to document to the required result: but I dont want any interactive
interaction!!
So I tried the following:
Sub Test()
Documents.Add
With ActiveDocument
Selection.TypeText Text:="=rand(3,5)"
Selection.TypeParagraph
End With
End Sub
Same result: text =rand(3,5) in the document and same behaviour:
pressing <enter> changes it.
So another try:
Sub Test()
Documents.Add
With ActiveDocument
Selection.TypeText Text:="=rand(3,5)"
Call SendKeys("%{ENTER}")
End With
End Sub
This should do !! But no: now I enter with a document with the
following line:
=rand(3,5)=rand(3,5) (???...)
So my question is: how can I use the =rand(x,y) in a macro?
Regards,
Hans Troost