Calling a GUI from excel and keeping it open

조회 수: 4 (최근 30일)
Johan
Johan 2011년 6월 6일
Hi there, need a way to keep a GUI called from excel VBA code open, I am using matlab automation server as my code below shows:
Private Sub openmatlab()
Dim hMatlab As Object
Dim sDir As String, scdDir As String, s1 As String
Dim Result As String
Set hMatlab = CreateObject("matlab.application")
s1 = "'"
sDir = s1 & ActiveWorkbook.path & s1
scdDir = "cd(" & sDir & ")"
hMatlab.Execute (scdDir)
Result = hMatlab.Execute("starter")
MsgBox "Matlab er lukket", vbOK, "Matlab"
End Sub
As you might be able to see I am using a messagebox to stop the GUI from shutting down, but that makes excel "blink" all the time, and is annoying, any thoughts on how to do it better?

답변 (2개)

Robert Cumming
Robert Cumming 2011년 6월 6일
In your VBA code you could try the option
Application.ScreenUpdating = False
I have no experience of running matlab from Excel, but that used to stop the "blinking" back in the day when I ran macros.
  댓글 수: 2
Johan
Johan 2011년 6월 6일
yeah, already tried that, but it doesn't work, besides I would like a solution that doesn't involve using the msgbox, which is kinda 'cheating' in my opinion.
Johan
Johan 2011년 6월 6일
But thanx anyways ;)

댓글을 달려면 로그인하십시오.


Johan
Johan 2011년 6월 7일
really no thoughts on this?
  댓글 수: 2
Robert Cumming
Robert Cumming 2011년 6월 7일
if you provide a bit more details?
What is your matlab function doing? Is it a GUI? and do you want to wait until the GUI closes before control returns to excel?
If so have you tried uiwait(yourGUIHandle). That should stop it.
Johan
Johan 2011년 6월 16일
thanx a lot.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by