×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Import a UserForm in Excel VBA

Import a UserForm in Excel VBA

Import a UserForm in Excel VBA

(OP)
I have to import a "base" UserForm, add some controls and code and then show the form.
Using the code included below, the problem I have is that when VBA executes VBA.UserForms.Add(NewTempForm.Name).Show, the report goes back to the base (as imported).
To verify what instruction was deleting my changes I generated a run-time error in different parts of the code and checked the UserForm Manually.

1) Is there any way to execute this code Step by Step?
(Now I get the error "Can't enter break mode at this time")

2) Is there other way to show the form without loosing my changes?

Thanks,
Leo.


The code I am using is:

'Import Base Form
Set NewTempForm = ThisWorkbook.VBProject.VBComponents.Import(ThisWorkbook.Path & "\" & FORM_NAME)

'Set Properties
With NewTempForm
    .Properties("Caption") = NewTempForm.Name
    .Properties("Height").Value = .Properties("Height").Value + No * DELTA_H
End With

'Add Event Code Here
'Code removed for simplicity
'
'End of Code

'Show Form
VBA.UserForms.Add(NewTempForm.Name).Show

'Remove Form
ThisWorkbook.VBProject.VBComponents.Remove (NewTempForm)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources