Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default How to run Solver from Visual Basic?

I have an Access database application that creates an excel application, an
excel spreadsheet and formats all the data in the appropriate rows and
columns of a worksheet. I would like to launch Solver from the new excel
application, but I cannot run it. I have loaded solver in my references, and
if I look through the addins of the newly created spreadsheet, it's there. Of
course, Access itself does not recognize the solver addin.
Any ideas (including how to generate excel modules from an access program,
then execute the resulting module)? Alternatively, is there a similar addin
for Access (sorry that this is not the forum for that)?
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default How to run Solver from Visual Basic?

If you are opening excel from access using automation, then addins are not
loaded automatically to speed things up.

Here is some sample Excel code to add the solver addin and crate a reference
to it:
(written by Dana DeLouise)

Sub SolverInstall()
'// Dana DeLouis
Dim wb As Workbook

On Error Resume Next
' Set a Reference to the workbook that will hold Solver
Set wb = ActiveWorkbook

With wb.VBProject.References
.Remove .Item("SOLVER")
End With

With AddIns("Solver Add-In")
.Installed = False
.Installed = True
wb.VBProject.References.AddFromFile .FullName
End With
End Sub

http://support.microsoft.com/default...b;en-us;843304
How to create Visual Basic macros by using Excel Solver in Excel 97

--
Regards,
Tom Ogilvy


"Dinosaur51" wrote:

I have an Access database application that creates an excel application, an
excel spreadsheet and formats all the data in the appropriate rows and
columns of a worksheet. I would like to launch Solver from the new excel
application, but I cannot run it. I have loaded solver in my references, and
if I look through the addins of the newly created spreadsheet, it's there. Of
course, Access itself does not recognize the solver addin.
Any ideas (including how to generate excel modules from an access program,
then execute the resulting module)? Alternatively, is there a similar addin
for Access (sorry that this is not the forum for that)?
Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default How to run Solver from Visual Basic?

I tried this from Access 2003 and got the following problems:
It would not let me access VBProject saying "Programmatic access to
VBProject not trusted."
the statement wb.VBProject.References.Remove.Item("SOLVER") came back
highlighting .Remove and saying "Argument not optional"
the statement app.wb.application solverOK (etc) returns a Function or
subfunction not defined.


I don't seem able to get beyond the compiler (interpreter, or whatever).
Thanks for your help.


"Tom Ogilvy" wrote:

If you are opening excel from access using automation, then addins are not
loaded automatically to speed things up.

Here is some sample Excel code to add the solver addin and crate a reference
to it:
(written by Dana DeLouise)

Sub SolverInstall()
'// Dana DeLouis
Dim wb As Workbook

On Error Resume Next
' Set a Reference to the workbook that will hold Solver
Set wb = ActiveWorkbook

With wb.VBProject.References
.Remove .Item("SOLVER")
End With

With AddIns("Solver Add-In")
.Installed = False
.Installed = True
wb.VBProject.References.AddFromFile .FullName
End With
End Sub

http://support.microsoft.com/default...b;en-us;843304
How to create Visual Basic macros by using Excel Solver in Excel 97

--
Regards,
Tom Ogilvy


"Dinosaur51" wrote:

I have an Access database application that creates an excel application, an
excel spreadsheet and formats all the data in the appropriate rows and
columns of a worksheet. I would like to launch Solver from the new excel
application, but I cannot run it. I have loaded solver in my references, and
if I look through the addins of the newly created spreadsheet, it's there. Of
course, Access itself does not recognize the solver addin.
Any ideas (including how to generate excel modules from an access program,
then execute the resulting module)? Alternatively, is there a similar addin
for Access (sorry that this is not the forum for that)?
Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default How to run Solver from Visual Basic?

Accest to the Project is a security setting made by the user. That can't be
overridden with code. YOu can change that in Excel in tools=Macros=Security

Trusted Publishers Tab,
at the bottom left, select the two checkboxes.


the code I posted looked like this:

With wb.VBProject.References
.Remove .Item("SOLVER")
End With

Note that there is a space between .Remove and .Item

--
Regards,
Tom Ogilvy

"Dinosaur51" wrote:

I tried this from Access 2003 and got the following problems:
It would not let me access VBProject saying "Programmatic access to
VBProject not trusted."
the statement wb.VBProject.References.Remove.Item("SOLVER") came back
highlighting .Remove and saying "Argument not optional"
the statement app.wb.application solverOK (etc) returns a Function or
subfunction not defined.


I don't seem able to get beyond the compiler (interpreter, or whatever).
Thanks for your help.


"Tom Ogilvy" wrote:

If you are opening excel from access using automation, then addins are not
loaded automatically to speed things up.

Here is some sample Excel code to add the solver addin and crate a reference
to it:
(written by Dana DeLouise)

Sub SolverInstall()
'// Dana DeLouis
Dim wb As Workbook

On Error Resume Next
' Set a Reference to the workbook that will hold Solver
Set wb = ActiveWorkbook

With wb.VBProject.References
.Remove .Item("SOLVER")
End With

With AddIns("Solver Add-In")
.Installed = False
.Installed = True
wb.VBProject.References.AddFromFile .FullName
End With
End Sub

http://support.microsoft.com/default...b;en-us;843304
How to create Visual Basic macros by using Excel Solver in Excel 97

--
Regards,
Tom Ogilvy


"Dinosaur51" wrote:

I have an Access database application that creates an excel application, an
excel spreadsheet and formats all the data in the appropriate rows and
columns of a worksheet. I would like to launch Solver from the new excel
application, but I cannot run it. I have loaded solver in my references, and
if I look through the addins of the newly created spreadsheet, it's there. Of
course, Access itself does not recognize the solver addin.
Any ideas (including how to generate excel modules from an access program,
then execute the resulting module)? Alternatively, is there a similar addin
for Access (sorry that this is not the forum for that)?
Thanks

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default How to run Solver from Visual Basic?

Oh, the joys of proportional fonts! Thanks for the clarification. In Access,
one of the check boxes (the lower one) is "greyed out" and cannot be
selected. In Excel, I did it, but it does not save the setting and must be
set everytime by the user, in the newly created spreadsheet before the
statement is executed. I suppose being able to change that "programatically",
as they say, would be a breach of security! Once it is selected, it comes
back that "SOLVER" is out of range.
This seemed like such a good idea, too!

Do you know of any REASONABLY priced optimization packages (something less
than the $1500 that Solver.com wants), or a way to hack into solver.dll?

So near, yet so far!
Regards,
Mike

"Tom Ogilvy" wrote:

Accest to the Project is a security setting made by the user. That can't be
overridden with code. YOu can change that in Excel in tools=Macros=Security

Trusted Publishers Tab,
at the bottom left, select the two checkboxes.


the code I posted looked like this:

With wb.VBProject.References
.Remove .Item("SOLVER")
End With

Note that there is a space between .Remove and .Item

--
Regards,
Tom Ogilvy

"Dinosaur51" wrote:

I tried this from Access 2003 and got the following problems:
It would not let me access VBProject saying "Programmatic access to
VBProject not trusted."
the statement wb.VBProject.References.Remove.Item("SOLVER") came back
highlighting .Remove and saying "Argument not optional"
the statement app.wb.application solverOK (etc) returns a Function or
subfunction not defined.


I don't seem able to get beyond the compiler (interpreter, or whatever).
Thanks for your help.


"Tom Ogilvy" wrote:

If you are opening excel from access using automation, then addins are not
loaded automatically to speed things up.

Here is some sample Excel code to add the solver addin and crate a reference
to it:
(written by Dana DeLouise)

Sub SolverInstall()
'// Dana DeLouis
Dim wb As Workbook

On Error Resume Next
' Set a Reference to the workbook that will hold Solver
Set wb = ActiveWorkbook

With wb.VBProject.References
.Remove .Item("SOLVER")
End With

With AddIns("Solver Add-In")
.Installed = False
.Installed = True
wb.VBProject.References.AddFromFile .FullName
End With
End Sub

http://support.microsoft.com/default...b;en-us;843304
How to create Visual Basic macros by using Excel Solver in Excel 97

--
Regards,
Tom Ogilvy


"Dinosaur51" wrote:

I have an Access database application that creates an excel application, an
excel spreadsheet and formats all the data in the appropriate rows and
columns of a worksheet. I would like to launch Solver from the new excel
application, but I cannot run it. I have loaded solver in my references, and
if I look through the addins of the newly created spreadsheet, it's there. Of
course, Access itself does not recognize the solver addin.
Any ideas (including how to generate excel modules from an access program,
then execute the resulting module)? Alternatively, is there a similar addin
for Access (sorry that this is not the forum for that)?
Thanks



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default How to run Solver from Visual Basic?

Correction to my previous reply. Once the created spreadsheet was closed, now
new spreadsheets are created with that box checked. The other comment of
subscript out of range still applies, though.
Thx
Mike

"Tom Ogilvy" wrote:

Accest to the Project is a security setting made by the user. That can't be
overridden with code. YOu can change that in Excel in tools=Macros=Security

Trusted Publishers Tab,
at the bottom left, select the two checkboxes.


the code I posted looked like this:

With wb.VBProject.References
.Remove .Item("SOLVER")
End With

Note that there is a space between .Remove and .Item

--
Regards,
Tom Ogilvy

"Dinosaur51" wrote:

I tried this from Access 2003 and got the following problems:
It would not let me access VBProject saying "Programmatic access to
VBProject not trusted."
the statement wb.VBProject.References.Remove.Item("SOLVER") came back
highlighting .Remove and saying "Argument not optional"
the statement app.wb.application solverOK (etc) returns a Function or
subfunction not defined.


I don't seem able to get beyond the compiler (interpreter, or whatever).
Thanks for your help.


"Tom Ogilvy" wrote:

If you are opening excel from access using automation, then addins are not
loaded automatically to speed things up.

Here is some sample Excel code to add the solver addin and crate a reference
to it:
(written by Dana DeLouise)

Sub SolverInstall()
'// Dana DeLouis
Dim wb As Workbook

On Error Resume Next
' Set a Reference to the workbook that will hold Solver
Set wb = ActiveWorkbook

With wb.VBProject.References
.Remove .Item("SOLVER")
End With

With AddIns("Solver Add-In")
.Installed = False
.Installed = True
wb.VBProject.References.AddFromFile .FullName
End With
End Sub

http://support.microsoft.com/default...b;en-us;843304
How to create Visual Basic macros by using Excel Solver in Excel 97

--
Regards,
Tom Ogilvy


"Dinosaur51" wrote:

I have an Access database application that creates an excel application, an
excel spreadsheet and formats all the data in the appropriate rows and
columns of a worksheet. I would like to launch Solver from the new excel
application, but I cannot run it. I have loaded solver in my references, and
if I look through the addins of the newly created spreadsheet, it's there. Of
course, Access itself does not recognize the solver addin.
Any ideas (including how to generate excel modules from an access program,
then execute the resulting module)? Alternatively, is there a similar addin
for Access (sorry that this is not the forum for that)?
Thanks

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default How to run Solver from Visual Basic?

You can open solver just like a workbook using workbooks.open

that would get it loaded. Whether it would then work properly with code, I
can't say, but it is worth testing.
Solver is a generalized optimizer (therefore probably involved and complex)
- if you have a specific problem, perhaps you can code the algorithm to solve
it.

--
Regards,
Tom Ogilvy


"Dinosaur51" wrote:

Correction to my previous reply. Once the created spreadsheet was closed, now
new spreadsheets are created with that box checked. The other comment of
subscript out of range still applies, though.
Thx
Mike

"Tom Ogilvy" wrote:

Accest to the Project is a security setting made by the user. That can't be
overridden with code. YOu can change that in Excel in tools=Macros=Security

Trusted Publishers Tab,
at the bottom left, select the two checkboxes.


the code I posted looked like this:

With wb.VBProject.References
.Remove .Item("SOLVER")
End With

Note that there is a space between .Remove and .Item

--
Regards,
Tom Ogilvy

"Dinosaur51" wrote:

I tried this from Access 2003 and got the following problems:
It would not let me access VBProject saying "Programmatic access to
VBProject not trusted."
the statement wb.VBProject.References.Remove.Item("SOLVER") came back
highlighting .Remove and saying "Argument not optional"
the statement app.wb.application solverOK (etc) returns a Function or
subfunction not defined.


I don't seem able to get beyond the compiler (interpreter, or whatever).
Thanks for your help.


"Tom Ogilvy" wrote:

If you are opening excel from access using automation, then addins are not
loaded automatically to speed things up.

Here is some sample Excel code to add the solver addin and crate a reference
to it:
(written by Dana DeLouise)

Sub SolverInstall()
'// Dana DeLouis
Dim wb As Workbook

On Error Resume Next
' Set a Reference to the workbook that will hold Solver
Set wb = ActiveWorkbook

With wb.VBProject.References
.Remove .Item("SOLVER")
End With

With AddIns("Solver Add-In")
.Installed = False
.Installed = True
wb.VBProject.References.AddFromFile .FullName
End With
End Sub

http://support.microsoft.com/default...b;en-us;843304
How to create Visual Basic macros by using Excel Solver in Excel 97

--
Regards,
Tom Ogilvy


"Dinosaur51" wrote:

I have an Access database application that creates an excel application, an
excel spreadsheet and formats all the data in the appropriate rows and
columns of a worksheet. I would like to launch Solver from the new excel
application, but I cannot run it. I have loaded solver in my references, and
if I look through the addins of the newly created spreadsheet, it's there. Of
course, Access itself does not recognize the solver addin.
Any ideas (including how to generate excel modules from an access program,
then execute the resulting module)? Alternatively, is there a similar addin
for Access (sorry that this is not the forum for that)?
Thanks

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I use Visual Basic to access Solver? Jeff Excel Programming 1 September 14th 06 12:45 AM
Can I run Visual Basic procedure using Excel Visual Basic editor? john.jacobs71[_2_] Excel Programming 3 December 26th 05 02:22 PM
changing the visual basic in office 2003 to visual studio net bigdaddy3 Excel Discussion (Misc queries) 1 September 13th 05 10:57 AM
Solver in Visual Basic Cardiff Maths Student Excel Programming 0 April 5th 05 03:15 PM
Visual Basic Macro For Solver Velero Excel Programming 3 February 19th 04 07:09 AM


All times are GMT +1. The time now is 12:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"