PC Review


Reply
Thread Tools Rate Thread

Best way to call stored procedure, have results return in cell ran

 
 
SQLScott
Guest
Posts: n/a
 
      27th Oct 2008
I am totally new to Excel programming, so please be patient with me while I
try and explain what it is that I need.

I would like to call a stored procedure from Excel and have the results
placed in a specific range of cells, for example starting at D7 to K7 for
however many rows are returned.

So my question is this: What is the best way to call the Stored Procedure
and how do i place the results in a specific range of cells?

Should I place a button on the page and call the proc on the click event?

Any advise is greatly appreciated.

--
Thanks,

Scott
 
Reply With Quote
 
 
 
 
dmoney
Guest
Posts: n/a
 
      27th Oct 2008
where is the procedure? in an excel module? if so, you can use Call xxx
xxxbeing the name of the sub routine. Otherwise, more information is needed
to be able to assist.

"SQLScott" wrote:

> I am totally new to Excel programming, so please be patient with me while I
> try and explain what it is that I need.
>
> I would like to call a stored procedure from Excel and have the results
> placed in a specific range of cells, for example starting at D7 to K7 for
> however many rows are returned.
>
> So my question is this: What is the best way to call the Stored Procedure
> and how do i place the results in a specific range of cells?
>
> Should I place a button on the page and call the proc on the click event?
>
> Any advise is greatly appreciated.
>
> --
> Thanks,
>
> Scott

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      27th Oct 2008
Assume your procedure exists and is error free if run. The first line of
code is the title line. for example:

Sub myProcedure()
'Lot's of events
End Sub

The above procedure's name is "myProcedure"

When you record a procedure, there is usually a dialog box that appears and
asks if you want to assign a shortcut key. At that time you can pick any
letter of the alphabet as a shortcut key. To use that key to call the
procedure, you mus press the Ctl key and hold it while pressing your shortcut
key.

To assign a shortcut key to an existing procedure that was not recorded,
click Tools>Macro>Macros and left click the name of your procedure to make it
appear in the small window of the dialog box. Then click Options at the
bottom of the dialog box and when the Macro Options dialog box appears, type
the keyboard letter in the small box and click OK, then Cancel or the big X
on the Macro dialog box.

If you want to use a button, there are two sources for the button. One is
from the forms toolbar. If you use that button, you put the button on the
sheet, then right click it and select "Assign Macro" from the drop down menu
and basically follow the prcedure above for the Macro Options box.

If you use the button from the Control Toolbox, then when you put the b
utton on the sheet, you must be in design mode to right click the button and
from the drop down menu select "View Code" When the code window opens, put
this paste this code into the code window.

Private Sub CommandButton1_Click()
myProcedure
End Sub

This assumes that myProcedure is in the standard module1 code module.

If you want to run the code for editorial purposes, you can open the VB
editor and click the run button or you can click Tools>Macro>Macros then
click on the procedure you want and click Run.

That's pretty much it!

"SQLScott" wrote:

> I am totally new to Excel programming, so please be patient with me while I
> try and explain what it is that I need.
>
> I would like to call a stored procedure from Excel and have the results
> placed in a specific range of cells, for example starting at D7 to K7 for
> however many rows are returned.
>
> So my question is this: What is the best way to call the Stored Procedure
> and how do i place the results in a specific range of cells?
>
> Should I place a button on the page and call the proc on the click event?
>
> Any advise is greatly appreciated.
>
> --
> Thanks,
>
> Scott

 
Reply With Quote
 
SQLScott
Guest
Posts: n/a
 
      28th Oct 2008
I guess I should have been more specific.

I want to call a SQL Server stored procedure from within Excel and populate
a specific range of cells with the results returned from the SQL Server
stored procedure.

I hope this clarifies things...
--
Thanks,

Scott


"JLGWhiz" wrote:

> Assume your procedure exists and is error free if run. The first line of
> code is the title line. for example:
>
> Sub myProcedure()
> 'Lot's of events
> End Sub
>
> The above procedure's name is "myProcedure"
>
> When you record a procedure, there is usually a dialog box that appears and
> asks if you want to assign a shortcut key. At that time you can pick any
> letter of the alphabet as a shortcut key. To use that key to call the
> procedure, you mus press the Ctl key and hold it while pressing your shortcut
> key.
>
> To assign a shortcut key to an existing procedure that was not recorded,
> click Tools>Macro>Macros and left click the name of your procedure to make it
> appear in the small window of the dialog box. Then click Options at the
> bottom of the dialog box and when the Macro Options dialog box appears, type
> the keyboard letter in the small box and click OK, then Cancel or the big X
> on the Macro dialog box.
>
> If you want to use a button, there are two sources for the button. One is
> from the forms toolbar. If you use that button, you put the button on the
> sheet, then right click it and select "Assign Macro" from the drop down menu
> and basically follow the prcedure above for the Macro Options box.
>
> If you use the button from the Control Toolbox, then when you put the b
> utton on the sheet, you must be in design mode to right click the button and
> from the drop down menu select "View Code" When the code window opens, put
> this paste this code into the code window.
>
> Private Sub CommandButton1_Click()
> myProcedure
> End Sub
>
> This assumes that myProcedure is in the standard module1 code module.
>
> If you want to run the code for editorial purposes, you can open the VB
> editor and click the run button or you can click Tools>Macro>Macros then
> click on the procedure you want and click Run.
>
> That's pretty much it!
>
> "SQLScott" wrote:
>
> > I am totally new to Excel programming, so please be patient with me while I
> > try and explain what it is that I need.
> >
> > I would like to call a stored procedure from Excel and have the results
> > placed in a specific range of cells, for example starting at D7 to K7 for
> > however many rows are returned.
> >
> > So my question is this: What is the best way to call the Stored Procedure
> > and how do i place the results in a specific range of cells?
> >
> > Should I place a button on the page and call the proc on the click event?
> >
> > Any advise is greatly appreciated.
> >
> > --
> > Thanks,
> >
> > Scott

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Call a "Select" stored procedure with DAO or ODBC direct then return parameters derek Microsoft Access VBA Modules 1 26th Dec 2007 10:32 AM
Need help: Call server side Stored Procedure and get the return va =?Utf-8?B?ZGF2aWQ=?= Microsoft ASP .NET 3 20th Oct 2006 05:09 PM
Call Stored Procedure via ASP.Net (VB) Sam Microsoft ASP .NET 6 11th May 2005 05:06 PM
How to call parameterized stored procedure to return result set? Lacka Microsoft ASP .NET 2 31st Dec 2004 03:39 PM
Best way to call a stored procedure mike Microsoft C# .NET 1 16th Jun 2004 06:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:25 AM.