Sendkeys vs. Selection.TypeText

F

FUBARinSFO

Hi:

Out of old-timey recollection, I tried to use Sendkeys in Word 2003 to
enter some text. But it didn't work, and I had to resort to
Selection.TypeText. Code below.

If someone would be kind enough to clarify why Sendkeys doesn't work
in this context I would appreciate it very much.

-- Roy Zider

Sub PrintLayoutView()
'
' PrintLayoutView Macro
' Macro recorded 12/3/2007 by Roy Zider
'
' Developed to set invoice view to Print Layout View
'
Selection.HomeKey Unit:=wdStory
Selection.EndKey Unit:=wdLine
' .. this doesn't work:
' SendKeys "x", True
' SendKeys "{BS}", True
' .. this does:
Selection.TypeText Text:="x"
Selection.TypeBackspace

If ActiveWindow.View.SplitSpecial = wdPaneNone Then
ActiveWindow.ActivePane.View.Type = wdPrintView
Else
ActiveWindow.View.Type = wdPrintView
End If
ActiveWindow.Close
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top