A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Two questions about how to use textboxes in userforms



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old November 16th 08, 06:36 PM posted to microsoft.public.outlook.program_vba
MarceepooNu
external usenet poster
 
Posts: 17
Default Two questions about how to use textboxes in userforms

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
--
MarceepooNu
  #2  
Old November 17th 08, 07:13 PM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Two questions about how to use textboxes in userforms



You're funny. You have a working example, then you change a line of the
code, and it stopps working. And you don't get what might be wrong? :-)

#2: Not sure what that is. Maybe you need to save the project first?
Actually, once the file has been removed it shoudl be possible to create it
again.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: http://www.vboffice.net/product.html?pub=6&lang=en


Am Sun, 16 Nov 2008 10:36:08 -0800 schrieb 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

  #3  
Old November 17th 08, 07:28 PM posted to microsoft.public.outlook.program_vba
MarceepooNu
external usenet poster
 
Posts: 17
Default Two questions about how to use textboxes in userforms

I apologize for my ignorance. I don't understand what you're suggesting I do.
Perhaps I gave you the wrong impression of what I did. I created two
userforms in the project. One form is named: Userform1, and the other is
named: frmUserForm2

The code in each of the userforms is identical except for the name of the
form. Why does my changing the name of the form in the code (to match the
actual name I gave the form) stop the code from working?

Can you give me a hint where I could find some explanation? I'm sorry for
being obtuse. I really spent many hours trying to figure it out, before I
caved in and posted the question. I'm trying to be respectful of your time.
I just don't know what to do in order to figure this out.

Thanks again for taking the time to read this.

MarceepooNu


--
MarceepooNu


"Michael Bauer [MVP - Outlook]" wrote:



You're funny. You have a working example, then you change a line of the
code, and it stopps working. And you don't get what might be wrong? :-)

#2: Not sure what that is. Maybe you need to save the project first?
Actually, once the file has been removed it shoudl be possible to create it
again.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: http://www.vboffice.net/product.html?pub=6&lang=en


Am Sun, 16 Nov 2008 10:36:08 -0800 schrieb 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


  #4  
Old November 17th 08, 07:36 PM posted to microsoft.public.outlook.program_vba
MarceepooNu
external usenet poster
 
Posts: 17
Default Two questions about how to use textboxes in userforms

Hi. I just figured Problem #1 out ... with your help. How stupid of me!
Sorry for wasting your time.

But Problem #2 remains an enigma. I have compiled and saved and closed and
reopened the Project, and opened and closed Outlook many times. But if I
create a new form, and I attempt to name it "frmUserForm1", which is the name
of a form that I removed, I get an error message: "Path/file access error.

Do you have any suggestions where I could find out what's going on? I'm
worried that this might be a sign of some corruption in the Project, and that
I should fix it before it gets worse. But I really have no idea what's going
on.

Thanks again for your help.

--
MarceepooNu


"Michael Bauer [MVP - Outlook]" wrote:



You're funny. You have a working example, then you change a line of the
code, and it stopps working. And you don't get what might be wrong? :-)

#2: Not sure what that is. Maybe you need to save the project first?
Actually, once the file has been removed it shoudl be possible to create it
again.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: http://www.vboffice.net/product.html?pub=6&lang=en


Am Sun, 16 Nov 2008 10:36:08 -0800 schrieb 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


  #5  
Old November 17th 08, 07:52 PM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Two questions about how to use textboxes in userforms



I'm sorry, I have no solution to #2. If the project file is corrupt, this
might help: Export all of your project files, close Outlook, and delete the
*.otm project file. Then re-open Outlook, start the VBA editor, and import
your project files and save, which creates a new project file.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: http://www.vboffice.net/product.html?pub=6&lang=en


Am Mon, 17 Nov 2008 11:36:10 -0800 schrieb MarceepooNu:

Hi. I just figured Problem #1 out ... with your help. How stupid of me!
Sorry for wasting your time.

But Problem #2 remains an enigma. I have compiled and saved and closed

and
reopened the Project, and opened and closed Outlook many times. But if I
create a new form, and I attempt to name it "frmUserForm1", which is the

name
of a form that I removed, I get an error message: "Path/file access error.

Do you have any suggestions where I could find out what's going on? I'm
worried that this might be a sign of some corruption in the Project, and

that
I should fix it before it gets worse. But I really have no idea what's

going
on.

Thanks again for your help.

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
change the default font settings for a new label on userforms? Southern at Heart Outlook and VBA 1 February 20th 08 06:07 PM
OE questions fvdasvsd Outlook - General Queries 5 August 14th 07 03:33 PM
some oe6 questions \Coffeehouse Schmuck\ Outlook Express 3 March 18th 06 02:03 AM
OE 6 questions gregfarr Outlook Express 1 March 4th 06 11:21 PM
VBA UserForms and Scroll Wheel Sanjay Singh Outlook and VBA 0 January 24th 06 09:13 PM


All times are GMT +1. The time now is 10:39 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.