View Full Version : Code Replacement for SendKeys {Down 2}


Mike375
07-03-2008, 08:47 PM
Anyone got a replacement.

My basic problem is that when Access opens a Word.doc the cursor is set to land on a bookmark and the SendKeys {Down 2} drops it two more spaces , ready for typing. I can move the bookmark down but people can easily rub them out.

SendKeys is a "no goer" in Vista

chergh
07-03-2008, 11:26 PM
Use the word "movedown" method.

Mike375
07-04-2008, 01:14 AM
I am lost with what to do with it. Did some searching.

Private Sub Label306_Click()


Dim WordObj As Word.Application
Dim WordDoc As Word.Document
Dim WordRange As Word.Range
Set WordObj = CreateObject("Word.Application")
Set WordDoc = WordObj.Documents.Open _
("C:\Letters\0Letter1Mike.doc")
WordObj.Visible = True

Set WordRange = WordDoc.GoTo(What:=wdGoToBookmark, Name:="a7")

WordDoc.Bookmarks("a7").Select

Is there a way I can use it to drop two lines below Bookmark a7. Use to have a a runmacro at that is point running the SendKeys.

chergh
07-04-2008, 01:30 AM
Did you not read the helpfile? Movedown is a method of the selection object. You would use it like this:


Sub bleh()

Dim sel As Selection

ActiveDocument.Bookmarks("a7").Select

Set sel = Selection

sel.MoveDown unit:=wdLine, Count:=2

End Sub

Mike375
07-04-2008, 09:09 AM
I had mixed reesults. When a problem came up it was ActiveDocument.Bookmarks("a7").Select

Buy I was putting it in Access. Is this supposed to go in the Word.docs.

Rich
07-04-2008, 09:18 AM
Did you not read the helpfile
Any Microsoft help file made and shipped prior to 2007 does not work in Vista:rolleyes:

chergh
07-04-2008, 09:37 AM
I tested the code using word but the activedocument is a bad idea when the code is in access use:


WordDoc.Bookmarks("a7").Select