Substitute for SendKeys?

G

Guest

If I click on a hyperlink in a worksheet that sends me to another location in
the workbook, I can return with ALT-BACKARROW. In VBA, I can return with:

Application.SendKeys "%{LEFT}"

Can I do the same thing without SendKeys?
 
P

Peter T

Hmm, the references must be stored somewhere but try this workaround -

Sub test()
Dim c As CommandBarButton

Set c = CommandBars.FindControl(ID:=1017) ' Back
On Error Resume Next
c.Execute
If Err.Number Then
Set c = CommandBars.FindControl(ID:=1018) ' Forward
c.Execute
End If

End Sub

Regards,
Peter T
 
G

Guest

Thank you!
--
Gary''s Student - gsnu200750


Peter T said:
Hmm, the references must be stored somewhere but try this workaround -

Sub test()
Dim c As CommandBarButton

Set c = CommandBars.FindControl(ID:=1017) ' Back
On Error Resume Next
c.Execute
If Err.Number Then
Set c = CommandBars.FindControl(ID:=1018) ' Forward
c.Execute
End If

End Sub

Regards,
Peter T
 

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