![]() |
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 |
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 |
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 |
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 |
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 |
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-容 ----------------------------------------------------------------------- T-容x's Profile: http://www.excelforum.com/member.php...fo&userid=2657 View this thread: http://www.excelforum.com/showthread.php?threadid=46616 |
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-容x" 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-容x ------------------------------------------------------------------------ T-容x's Profile: http://www.excelforum.com/member.php...o&userid=26572 View this thread: http://www.excelforum.com/showthread...hreadid=466165 |
All times are GMT +1. The time now is 10:28 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com