Results 1 to 6 of 6

Thread: VBA - VB.Net - Integrating

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2004
    Location
    Argentina
    Posts
    7

    Resolved VBA - VB.Net - Integrating

    Hi, I need assistance on how I could have VBA currently running in Excel to notify events to a VB.Net system.

    VBA code is continuosly processing data. My idea is to modify it in a way that, under given circumstances, it would post/queue something to a VB.Net "listener" which would then take action.

    If I am not clear enough, please let me know.

    Thanks in advance


    Diego
    Last edited by dvillecco; Oct 5th, 2004 at 10:53 PM.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    One way (I'm sure there are a few) would be in VBA to write some
    code to output a text file or something to a directory whe
    something meets your criteria. Then in VB.NET write some code to
    watch this folder for the change event. Then when that happens
    you could read in the file, then dispose of it, do something based
    on the file contents and wait for the next file.

    HTH
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2004
    Location
    Argentina
    Posts
    7

    MSMQ

    Hi, In the meanwhile, I have been doing some research in the microsoft's knowledge base and, although I have never used it, I thought of the idea of using MSMQ.
    Don´t know yet if this would be the right approach but the problem with text files or that kind of stuff is that, for the problem I need to solve, I will need many many transactions/messages to be sent from VBA to .Net very fast and also to manage a sort of priority message queues.

    I´ll keep researching but so far, I find MSMQ the most adequate way to send messages from VBA to be watched by .Net and perform actions.

    Would VSTO help in any way for this?

    Thanks


    Diego

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Since you have allot of transactions you could also use SendMessage
    API to your VB.NET application. Easier than message queueing.

    You can send the messages to a bunch of different textboxes
    or ??? Each for a specific category from your Excel VBA.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    New Member
    Join Date
    Sep 2004
    Location
    Argentina
    Posts
    7

    API

    How would that be? I mean, can you give me some sample code as to send a message from VBA using that API?


    Thx

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Here are the basic APIs you will need. You may need more, like
    for subclassing depending on how your transaction are and
    frequency. Its not too hard to setup. Try a search or the API FAQ
    for a better understanding.

    VB Code:
    1. Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" _
    2. (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    3.  
    4. Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" _
    5. (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    6.  
    7. Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" _
    8. (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As Any) As Long
    HTH
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width