web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

VBA Keystroke Code is Not Working

(0) ShareShare
ReportReport
Posted on by

Hello:

At the end of my posting, here, is my VBA code.  I'm trying to tell GP 2013 R2 (12.00.1920) to press "Ctrl+O", after a certain window opens.  So, I'm using "SendKeys".

Although I receive no error, "Ctrl+O" does not happen.

I have tried using this code on several events, including "AfterOpen()".  But, the keyboard combination of "Ctrl+O" like I said just isn't happening.

Yes, this is for accessing the "View" menu in the window, in order to allow for the "Originating" currency selection to be selected by default, when the user opens the window.

The Currency Button that normally accomplishes the same thing is not in this window.  That's why I'm trying to get VBA to use keystrokes.

Any ideas?

Thanks!

John

Private Sub Window_AfterOpen()
SendKeys "^{O}"
End Sub

*This post is locked for comments

I have the same question (0)
  • Almas Mahfooz Profile Picture
    11,009 User Group Leader on at

    Which window you are trying to do this?

  • Community Member Profile Picture
    on at

    Hi Almas:

    Last night (PDT), I may have found a way to accomplish the same thing through a GP macro with VBA's "SendKeys" syntax plus the use of the Action Pane selection for the "Windows Command Display" in GP User Preferences.

    But, in case this does not work, I'd like this other "SendKeys" alternative that I proposed.

    The window is the Collections Management Transaction Note Selection window.

    Thanks, Almas!  I have always appreciated your help!

    John

  • Suggested answer
    Almas Mahfooz Profile Picture
    11,009 User Group Leader on at

    Why don't you just set view menu to originating after collection management window gets open? I don't have collection management installed currently but I have done similarly for sales transaction entry window and it's working.

  • Community Member Profile Picture
    on at

    Hi Almas:

    That's a good point!  I did not realize that you could do that in VBA.  Can you, literally, add the "View" menu selection to the Visual Basic Editor and manipulate its settings in the Editor?  if so, could you please tell me how?

    I went ahead and did the same thing, by using the KnowledgeBase article teaching how to use a macro combined with VBA's "SendKeys" syntax.  

    But, I'd prefer a more succinct way of handling this, especially in case there are any issues with what I did.

    Thanks, again, Almas!!!

    John

  • Suggested answer
    Almas Mahfooz Profile Picture
    11,009 User Group Leader on at

    Not much work

    Add window to Visual basic Editor by going to Tools>>Customize>>Add current window to visual basic.

    then add field to visual basic by going to Tools>>Customize>>Add Fields to Visual Basic and a plus sign came, click it over currency view. and then set Currency view button value to Originating option.

    My Sales transaction window code is something like that

    Private Sub Window_AfterOpen()


        CurrencyViewButton.Value = 2
      
    End Sub

  • Community Member Profile Picture
    on at

    Actually, there's no Currency View button in the window.  That's the problem.  :(  In fact, that would have been the first thing that I would have done.  

    John

  • Almas Mahfooz Profile Picture
    11,009 User Group Leader on at

    don't be so sad. :)

    we can find some work around. Let me install CM.

    almas

  • Community Member Profile Picture
    on at

    Thank you, Almas!

    Like I was saying earlier, I really wish that my original idea of using "SendKeys" to allow for punching "Ctrl+O" would have worked.

    Anyway, you navigate to this window by going to Transactions...Sales...Collections Main.  Then, you pull up a customer and click the "New Note" button.

    In the window that appears, put in an "Action ID" in its field.

    Next, click the expansion arrow where the "selected documents" field is.  (I may be a little "fuzzy", on that field's name.)

    Finally, the window appears.

    Thanks, again, so much!

    John

  • Verified answer
    Almas Mahfooz Profile Picture
    11,009 User Group Leader on at

    John, it seems we are not left with many options while dealing with Menu items in Dynamics GP. : ( 

    But Since you already find the solution with macro, I think you will not have any issue.

    I have also used the macro, separately record it and then add it in navigation pan with a Keyboard Shortcut and then use it with SendKeys.

    Private Sub Window_AfterOpen()
    SendKeys "{F3}"
    End Sub

     

    CM.png

  • Community Member Profile Picture
    on at

    Thank you, Almas, for your excellent help!  Again, I have always appreciated it!  :)

    John

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

#1
mtabor Profile Picture

mtabor 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans