Posted to microsoft.public.excel.programming
|
|
Userform causes Excel to crash
Earlier you mentioned you need access to Visual Basic Project, why
Depending on what you are doing to what, where and when, you might be
triggering a recompile during run-time.
Regards,
Peter T
"Stu W" wrote in message
...
Yes, I've cleaned the code as suggested (both manually and using AppsPro's
code cleaner), but still have the same problem. I've isolated the problem
to
five controls on the user form. Excel will crash on *any* of the
following
statements:
ufMain.pg1Letter_ob.Value = True
ufMain.pg1Legal_ob = True
ufMain.pg1Portrait_ob = True
ufMain.pg1Landscape_ob = True
ufMain.pg1Shrink_chkbox = True
Excel does not crash if I include the following code in front of the above
statements:
Application.VBE.MainWindow.Visible = True
Application.VBE.MainWindow.Visible = False
or if I open up the VBE prior to running the code.
All code compiles cleanly, and is password protected. I've used Option
Explicit on all code. I have other option buttons and checkboxes on the
same
user form with statements as above that are not causing Excel to crash. I
am
using a multi page control on the form, and all of the above are on the
same
tab. I've tried moving these controls into and out of frames, with no
resolution to Excel crashing.
Stu W.
"shah shailesh" wrote:
Have you clean the codes as mentioned in my earlier post?
Regards,
Shailesh Shah
http://in.geocities.com/shahshaileshs/
(Excel Add-ins Page)
If You Can't Excel with Talent, Triumph with Effort.
"Stu W" wrote in message
...
Thanks, this works, and is a suitable work-around. But man, wish I
didn't
have to do this.
"shah shailesh" wrote:
If you can enable Trust access to visual basic project, this error
will
not
display.
ToolsmacrosSecuritiesTrusted Publishers Tickmark Trust access to
visual
basic project.
Regards,
Shailesh Shah
http://in.geocities.com/shahshaileshs/
(Excel Add-ins Page)
If You Can't Excel with Talent, Triumph with Effort.
"Stu W" wrote in message
...
Well, interesting work-around idea. Doesn't really solve the
source
problem,
but might be a temporary solution until the real problem is
identified.
When I run the code below I get a error message:
Run-time error '1004':
Programmatic access to Visual Basic Project is not trusted
any ideas?
"shah shailesh" wrote:
Here's an update... I can run the code if I first open up the
vba
development environment and display the code. If I don't do
that
first,
then
running the code causes Excel to crash. I don't have to change
anything,
I
just have to look at the code.
In this case you can add below code as under:
Public Sub ShowUFMain()
On Error GoTo ErrorRoutine
With Application.VBE.MainWindow
.Visible = True
.Visible = False
End With
ufMain.Show
ErrorRoutine:
modErrorHandle.ErrorHandling "modStartform.ShowUFMain"
End Sub
You may clean the codes by exporting each modules & userforms &
again
import
them. You may download free addins for code cleaner. Have a google
search.
You can also download my free comaddins "File Sizer" from
Com-Addins
page
of
below site.
Regards,
Shailesh Shah
http://in.geocities.com/shahshaileshs/
(Excel Add-ins Page)
If You Can't Excel with Talent, Triumph with Effort.
"Stu W" wrote in message
...
Here's an update... I can run the code if I first open up the
vba
development environment and display the code. If I don't do
that
first,
then
running the code causes Excel to crash. I don't have to change
anything,
I
just have to look at the code.
THere are times when I can run the code until I compile it and
password
protect the code. Then it will cause Excel to crash.
Any ideas out there?
|