# Solved: Arrow Keys...



## RGregory (Jul 27, 2005)

I need to send the down arrow key (vbKeyDown) to Word to enter text into a graph on a page, but when I do a typetext vbKeyDown & "Message" the character code for the down arrow key (40) is displayed followed by "Message" (which is obviously not what I am trying to get) <G>.


----------



## lotuseclat79 (Sep 12, 2003)

RGregory said:


> I need to send the down arrow key (vbKeyDown) to Word to enter text into a graph on a page, but when I do a typetext vbKeyDown & "Message" the character code for the down arrow key (40) is displayed followed by "Message" (which is obviously not what I am trying to get) <G>.


Hi RGregory,

I don't know the hex value of any of the arrow keys (0x40 for the down arrow?) which you are trying to enter otherwise, what I do know is how to enter the symbol of an arrow key into a Word document which is quite easy. I don't know if this is what you are looking to do:

In the Word document, pull-down the Insert menu and select symbol then click on the arrow key of your choice which will be inserted at the current cursor location, and click the Insert button to do so.

-- Tom

P.S. decimal 40='(', octal 40='SP' i.e. a space, and hex 40='@'


----------



## cristobal03 (Aug 5, 2005)

RGregory said:


> I need to send the down arrow key (vbKeyDown) to Word to enter text into a graph on a page, but when I do a typetext vbKeyDown & "Message" the character code for the down arrow key (40) is displayed followed by "Message" (which is obviously not what I am trying to get) <G>.


I'm a little confused...it sounds like you want to insert a keypress event? That is, you want to use a key code constant to move the focus to a different part of the document? It's been forever since I worked with VB but I would imagine you'd have to handle that as a separate event. I might be pretty wrong about that.

HTH

chris.


----------



## RGregory (Jul 27, 2005)

I have a form I need to populate with data I retrieve from Access. This data has to go into a grid on a word document. There are a few items that need to be placed before the grid. Everything works fine until I get to the area of the document where the grid is. If I just use typetext to enter the data (using vbCrLf when going to another line), it will skip the grid entirely. I know I can get into the grid by pressing the down arrow key, but have been unable to send that character programmatically. When I look at the vb constant vbKeyDown I get...

asc(vbkeydown) = 52 
chr(vbkeydown) = (
vbkeydown = 40

which explains (to a point) why I receive the 40 on the document. But this, unfortunately, does nothing to solve the problem <G>.

I believe the sendkeys method may do the trick, but haven't been able to try this yet (just popped back into my head as I was typing this reply  )


----------



## cristobal03 (Aug 5, 2005)

RGregory said:


> This data has to go into a grid on a word document.


This might not even be a problem anymore, but I was just going through my subscriptions and I started thinking about this again. If by "grid" you mean a Word table, that _has_ to be an object. Well, not necessarily but I'd be really surprised if it wasn't. So you could check to see if the table object has any method that would allow you to select it or focus on it, and then put your data in it.

HTH

chris.


----------



## RGregory (Jul 27, 2005)

I am pretty sure it is an object (the grid), but have no idea how to go about selecting it from within access. I ended up changing the program so that Word is not used at all though. I just created an html form letter with a table to hold the data. Seems to work a LOT better that the older solution <G>. Plus the overhead of Word can be eliminated from the program altogether!
I love it when a plan comes together <G>.


----------



## cristobal03 (Aug 5, 2005)

Well done, glad you got this resolved.  You can mark this thread Solved by using the *Thread Tools* at the top of the window.

chris.


----------

