Hi,
I'm trying to run my MatLab program called regressionv3 from Excel with the following VBA code:
Call RunMatLab(regressionv3)
Sub RunMatLab(currPrgm)
Dim hMatlab As Object
Dim sDir As String, cdsDir As String, s1 As String
Dim Result As String
Set hMatlab = CreateObject("matlab.application")
s1 = "'"
sDir = s1 & runPath & s1
cdsDir = "cd(" & sDir & ")"
hMatlab.Execute (cdsDir)
Result = hMatlab.Execute(currPrgm)
If Result <> "" Then MsgBox Result
End Sub
The problem is that, during debug, I get the message regressionv3 = empty. When I run the code, I see the MatLab window flicker open and then close before it runs the program, and I do not get the output I expect (because the program is not running). Regressionv3 runs alright from MatLab, but if anyone can tell me how to make it run from Excel with this/more efficient code, I would appreciate it very much.
Thank you!
I'm trying to run my MatLab program called regressionv3 from Excel with the following VBA code:
Call RunMatLab(regressionv3)
Sub RunMatLab(currPrgm)
Dim hMatlab As Object
Dim sDir As String, cdsDir As String, s1 As String
Dim Result As String
Set hMatlab = CreateObject("matlab.application")
s1 = "'"
sDir = s1 & runPath & s1
cdsDir = "cd(" & sDir & ")"
hMatlab.Execute (cdsDir)
Result = hMatlab.Execute(currPrgm)
If Result <> "" Then MsgBox Result
End Sub
The problem is that, during debug, I get the message regressionv3 = empty. When I run the code, I see the MatLab window flicker open and then close before it runs the program, and I do not get the output I expect (because the program is not running). Regressionv3 runs alright from MatLab, but if anyone can tell me how to make it run from Excel with this/more efficient code, I would appreciate it very much.
Thank you!