Connection between Solver add-in and file path code

S

Schatzi

I am having a strange connection between my excel solver add-in and my
file path security macro. I am running an excel file from a server. On
my computer it runs just fine, but from the server there is a problem
linking the solver and file path code.
I have a file path code:

FullPath = ThisWorkbook.FullName
If FullPath <> "path\filename.xlsm" Then
MsgBox "This file can only be accessed from the server: " +
FullPath, vbExclamation, "Access Denied"
ActiveWorkbook.Close False
End If

Another piece of code requires excel solver. If I do not have excel
solver installed, then even when I just run this code I get an error
(only from the server). If I install the solver (by checking the box
in add-ins) then this file path code works too. I have the filepath
code in an auto_open sub. I wrote code to automatically install the
solver:

Private Sub Workbook_Open()
If AddIns("Solver Add-in").Installed = False Then
AddIns("Solver Add-in").Installed = True
End If
End Sub

This code seems to work, and I can see that solver is installed, but
then the filepath code still doesn't work. The filepath code only
works when I manually install the solver. I thought it might be an
order issue. I moved the filepath code to a different macro and had it
run after opening the workbook and it still doesn't work. The filepath
code only works when I manually install the solver before the code is
run, or if I have the macro install the solver and then close and re-
open the file. It doesn't run when I have the macro install solver and
then either automatically or manually run the filepath macro.

Any ideas as to why this is a problem?
Also, if I have the macro install the solver and then I go through the
filepath code step by step the macro works just fine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top