Macro to Simulate F2

L

Lil Pun

I have a macro setup so when that the file is opened the cell A2 will be
in edit mode (the cursor or blinking line will be in cell A2) Here is
the macro:

Private Sub Workbook_Open()
Range("A2").Select
avoidloop = True
Application.SendKeys "{F2}"
End Sub

The problem is it only works when I open the file after opening Excel,
you know click on File -> click Open -> click Filename.xls then Open
and not when I directly open the file by double clicking it. Is there
anyway to fix it so that it opens that way anyway the file is opened?
 
L

Lil Pun

It is for a bar code scanner I am working on for somebody else. I ha
the program setup to where the cell was just active but the scanner di
not recognize this, it only recognizes when the cell is in edit mode no
just selected
 
R

RB Smissaert

It works with me both on opening the file when Excel is open already and
when double-clicking
the file when Excel is closed.
I had to un-install all add-ins though otherwise it would open the VBE and
not get A2 in edit mode.
Not sure yet why that happened.

RBS
 
R

RB Smissaert

Some add-ins cause this behaviour (F2 opening the VBE), for example Doug
Glancy's
FaceID viewer and some don't.
Can't see the pattern in this yet.
What happens with you then when you directly open the file when Excel is
closed?
Does it open the VBE as well?

RBS
 
L

Lil Pun

No it has never opened VBE, I haven't tried running the macro alone
though either. I just open the file that the macro is actually a part
of.
 
R

RB Smissaert

So what happens if you have a workbook with only this code:

Private Sub Workbook_Open()
Range("A2").Select
Application.SendKeys "{F2}"
End Sub

And nil else, and no add-ins installed and no personal.xls
running, just nothing else and then close Excel and double-click the file?
It then put A2 in edit mode with me.

RBS
 

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