M
MarceepooNu
The Outlook VBA help includes a page named: "Cut, Paste Methods, TextBox
Control Example"
A copy of the sample code is set forth below, except that I changed the
first line of the code from
Private Sub UserForm_Initialize()
to...
frmUserForm2
because I named the form: frmUserForm2
I created two forms in my Outlook VbaProject.Otm; one form was named:
UserForm and the other was named: frmUserForm2
The code works fine in the form named "UserForm", but when I tried to run
the same code in frmUserForm2's "Initialize" sub, nothing appears in the
textboxes.
Question #1: I can't figure out why changing the name of the form prevents
the code from working.
Also, I have noticed that if I remove a form from the project, and
thereafter create a new form and give it the same name as the form that I
removed, I get an error message: "Path/file access error. Question #2: Why
does this occur, and how can I fix it?
Private Sub frmUserForm2_Initialize()
TextBox1.Text = "From TextBox1!"
TextBox2.Text = "Hello "
CommandButton1.Caption = "Cut and Paste"
CommandButton1.AutoSize = True
End Sub
Private Sub CommandButton1_Click()
TextBox2.SelStart = 0
TextBox2.SelLength = TextBox2.TextLength
TextBox2.Cut
TextBox1.SetFocus
TextBox1.SelStart = 0
TextBox1.Paste
TextBox2.SelStart = 0
End Sub
Control Example"
A copy of the sample code is set forth below, except that I changed the
first line of the code from
Private Sub UserForm_Initialize()
to...
frmUserForm2
because I named the form: frmUserForm2
I created two forms in my Outlook VbaProject.Otm; one form was named:
UserForm and the other was named: frmUserForm2
The code works fine in the form named "UserForm", but when I tried to run
the same code in frmUserForm2's "Initialize" sub, nothing appears in the
textboxes.
Question #1: I can't figure out why changing the name of the form prevents
the code from working.
Also, I have noticed that if I remove a form from the project, and
thereafter create a new form and give it the same name as the form that I
removed, I get an error message: "Path/file access error. Question #2: Why
does this occur, and how can I fix it?
Private Sub frmUserForm2_Initialize()
TextBox1.Text = "From TextBox1!"
TextBox2.Text = "Hello "
CommandButton1.Caption = "Cut and Paste"
CommandButton1.AutoSize = True
End Sub
Private Sub CommandButton1_Click()
TextBox2.SelStart = 0
TextBox2.SelLength = TextBox2.TextLength
TextBox2.Cut
TextBox1.SetFocus
TextBox1.SelStart = 0
TextBox1.Paste
TextBox2.SelStart = 0
End Sub