• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 574
  • Last Modified:

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

0
suzygm71478
Asked:
suzygm71478
  • 2
1 Solution
 
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
 
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

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now