Use SendKeys Custom Code via Hyperlink Action

I want to use a SendKeys function to call a Windows application and open a record.

Is there a way to add this custom code to a Reporting Services report and use it through the Hyperlink action?  The desired effect is to let our users click on the link and have the windows application open to the account directly.

Thanks,

Susan
Sub Main()
        Dim ProcID As Integer
        ' Start the Calculator application, and store the process id.
        ProcID = Shell("""D:\Program Files\Diamond\UI\Diamond.exe""", AppWinStyle.NormalFocus)
        ' Activate the Calculator application.
        AppActivate(ProcID)
        ' Send the keystrokes to the Calculator application.
        My.Computer.Keyboard.SendKeys("{F3}", True)
        My.Computer.Keyboard.SendKeys("1006010860", True)
        My.Computer.Keyboard.SendKeys("{Enter}", True)
        ' My.Computer.Keyboard.SendKeys("=", True)
 
    End Sub

Open in new window

suzygm71478Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jgvCommented:
First part is possible. From the Layout tab, select Report >> Report Properties from the menu. Click on the Code tab. Paste this into the code window. The only thing changed was the procedure declaration and name. SSRS expects a return value when calling a custom procedure so it has to be a function.

Function ShowCalc() As Integer
        Dim ProcID As Integer
        ' Start the Calculator application, and store the process id.
        ProcID = Shell("""D:\Program Files\Diamond\UI\Diamond.exe""", AppWinStyle.NormalFocus)
        ' Activate the Calculator application.
        AppActivate(ProcID)
        ' Send the keystrokes to the Calculator application.
        My.Computer.Keyboard.SendKeys("{F3}", True)
        My.Computer.Keyboard.SendKeys("1006010860", True)
        My.Computer.Keyboard.SendKeys("{Enter}", True)
        ' My.Computer.Keyboard.SendKeys("=", True)
End Function

You can call this function from an expression like this:
=Code.ShowCalc()

The second part, calling this from a hyperlink, is not so easy. I spent some time trying to get it to work but no luck. SSRS wants to execute the code while it's rendering but does nothing when you click on the cell. You can play around with it; maybe there is a compromise you can make. If you put this in the details section of your report I suggest that you limit the number of records being returned to 3 or 4. As I mentioned, SSRS will fire this code while rendering the report...once for every record.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
suzygm71478Author Commented:
So maybe put this function in a subreport and use the hyplerlink to pass the parameter to it?  Thanks for the info, this is great help.
0
suzygm71478Author Commented:
Spectacular info.  Thanks so much.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.