Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default textbox trouble

Hello agian!

I'm trying to set a textbox for use later in the code.

Dim iBox as Textbox

if varTest = 1 then
Set iBox = Sheet1.textbox1
elseif varTest = 2 then
Set iBox = Sheet1.textbox2
elseif varTest = 3 then
Set iBox = Sheet1.textbox3
end if

with iBox
.text = "Test"
.enabled=False
etc...
end with

It errors during the Set iBox= line of codes, what am I doing wrong?

Thanks
Craig


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default textbox trouble

Hi Craig,

Set iBox = Sheet1.textbox1


Try:

Set ibox = Sheets("Sheet1").Shapes("textbox1")


---
Regards,
Norman



"Craig" wrote in message
news:ru9Ue.160385$Hk.63792@pd7tw1no...
Hello agian!

I'm trying to set a textbox for use later in the code.

Dim iBox as Textbox

if varTest = 1 then
Set iBox = Sheet1.textbox1
elseif varTest = 2 then
Set iBox = Sheet1.textbox2
elseif varTest = 3 then
Set iBox = Sheet1.textbox3
end if

with iBox
.text = "Test"
.enabled=False
etc...
end with

It errors during the Set iBox= line of codes, what am I doing wrong?

Thanks
Craig



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default textbox trouble

Try

If varTest = 1 Then
Set iBox = Sheets("Sheet1").TextBox1
etc

Hope this helps
Rowan

Craig wrote:
Hello agian!

I'm trying to set a textbox for use later in the code.

Dim iBox as Textbox

if varTest = 1 then
Set iBox = Sheet1.textbox1
elseif varTest = 2 then
Set iBox = Sheet1.textbox2
elseif varTest = 3 then
Set iBox = Sheet1.textbox3
end if

with iBox
.text = "Test"
.enabled=False
etc...
end with

It errors during the Set iBox= line of codes, what am I doing wrong?

Thanks
Craig


  #4   Report Post  
Posted to microsoft.public.excel.programming
Zoo Zoo is offline
external usenet poster
 
Posts: 40
Default textbox trouble

You may declare iBox as wrong Object type.

Try:

Dim iBox as msforms.TextBox

"Craig" wrote in message
news:ru9Ue.160385$Hk.63792@pd7tw1no...
Hello agian!

I'm trying to set a textbox for use later in the code.

Dim iBox as Textbox

if varTest = 1 then
Set iBox = Sheet1.textbox1
elseif varTest = 2 then
Set iBox = Sheet1.textbox2
elseif varTest = 3 then
Set iBox = Sheet1.textbox3
end if

with iBox
.text = "Test"
.enabled=False
etc...
end with

It errors during the Set iBox= line of codes, what am I doing wrong?

Thanks
Craig



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default textbox trouble

Hi Craig,

If the textboxes are from the control Toolbox, try something like:

..===========================
Sub TestIt()
Dim VarTest As Long
Dim iBox As OLEObject

'code to assign value to VarTest variable, e.g.:
VarTest = 2

Set iBox = Sheets("Sheet1").OLEObjects("textbox" & VarTest)

With iBox.Object
.Text = "Test"
.Enabled = False
End With

End Sub
'<<===========================


---
Regards,
Norman



"Craig" wrote in message
news:ru9Ue.160385$Hk.63792@pd7tw1no...
Hello agian!

I'm trying to set a textbox for use later in the code.

Dim iBox as Textbox

if varTest = 1 then
Set iBox = Sheet1.textbox1
elseif varTest = 2 then
Set iBox = Sheet1.textbox2
elseif varTest = 3 then
Set iBox = Sheet1.textbox3
end if

with iBox
.text = "Test"
.enabled=False
etc...
end with

It errors during the Set iBox= line of codes, what am I doing wrong?

Thanks
Craig





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default textbox trouble


Hi Craig! You can also just declare iBox as Object...

Dim iBox as Object
...
Set iBox = Sheet1.TextBox1
...



Craig Wrote:
Hello agian!

I'm trying to set a textbox for use later in the code.

Dim iBox as Textbox

if varTest = 1 then
Set iBox = Sheet1.textbox1
elseif varTest = 2 then
Set iBox = Sheet1.textbox2
elseif varTest = 3 then
Set iBox = Sheet1.textbox3
end if

with iBox
.text = "Test"
.enabled=False
etc...
end with

It errors during the Set iBox= line of codes, what am I doing wrong?

Thanks
Crai


--
T-®e
-----------------------------------------------------------------------
T-®ex's Profile: http://www.excelforum.com/member.php...fo&userid=2657
View this thread: http://www.excelforum.com/showthread.php?threadid=46616

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default textbox trouble

Yes... Thanks, I did declare it as an Object.... then all worked fine! You'd
figure if it was a TextBox you'd declare it as a Textbox! Go Figure!
Thanks Craig
"T-®ex" wrote in message
...

Hi Craig! You can also just declare iBox as Object...

Dim iBox as Object
..
Set iBox = Sheet1.TextBox1
..



Craig Wrote:
Hello agian!

I'm trying to set a textbox for use later in the code.

Dim iBox as Textbox

if varTest = 1 then
Set iBox = Sheet1.textbox1
elseif varTest = 2 then
Set iBox = Sheet1.textbox2
elseif varTest = 3 then
Set iBox = Sheet1.textbox3
end if

with iBox
.text = "Test"
.enabled=False
etc...
end with

It errors during the Set iBox= line of codes, what am I doing wrong?

Thanks
Craig



--
T-®ex
------------------------------------------------------------------------
T-®ex's Profile:
http://www.excelforum.com/member.php...o&userid=26572
View this thread: http://www.excelforum.com/showthread...hreadid=466165



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I have had trouble with textbox text to worksheet Thomas Excel Discussion (Misc queries) 1 March 10th 05 03:23 AM
HELP! I Lost The Ability To Advance From TextBox To TextBox With the ENTER Or The TAB Keys Minitman[_4_] Excel Programming 0 February 22nd 05 08:50 PM
Textbox Bug? Missing/delayed update of textbox filled via VBA MarcM Excel Programming 0 November 4th 04 05:47 PM
Textbox Bug? Missing/delayed update of textbox filled via VBA MarcM Excel Programming 0 November 4th 04 05:43 PM
Textbox trouble on a user form Oreg[_3_] Excel Programming 7 May 27th 04 12:36 AM


All times are GMT +1. The time now is 05:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"