[RESOLVED] Fill textbox from command button outlook vba
Hi title says it all really
I am running Outlook 2003 and the form is IPM.Note
i have managed to find the code editor on outlook(lol very basic), i need to modify an outlook form but before i set out on that journy was just trying some basic stuff fill a textbox from a command button.
did the following it keeps telling me the TextBox1 control is missing but it is on the form.
Code:
Sub Cmd1_click
Textbox1.Value = "Test"
End Sub
Button and textbox defiantly exist and i have checked the names i am guessing there maybe a page or form i need to put in front of the textbox1.value?
Re: Fill textbox from command button outlook vba
Quote:
Originally Posted by nabbster
maybe a page or form i need to put in front of the textbox1.value?
Even I think so. Though I haven't worked with outlook but i guess VBA is same everywhere (i could be wrong)....
Try
vb Code:
Sub Cmd1_click
UserForm1.Textbox1.Value = "Test"
End Sub
Where UserForm1 is the name of the form where the textbox is. the best way to check is the moment you type
UserForm1.Textbox1.
you should get a prompt automatically. if you don't then VBA is not able to recognise that particular control....
Hope this helps...
Re: Fill textbox from command button outlook vba
Bah thought so stupid thing is i cant find the name of the user form, i am used to going to properties and its there for you with this it isn't the case. any ideas how to find out the name of the form this control sits on?
Re: Fill textbox from command button outlook vba
Like i said, I have not worked with outlook. but my logic which again could be wrong is to double click on the form and a code window should open with the name of the form... something like
vb Code:
Private Sub UserForm_Click()
End Sub
Re: Fill textbox from command button outlook vba
Nope nothing happens if i double click it i thought same. i am sure your right about the controls path i tried a msgbox in the button click and it worked right off. thought i was loosing my mind for a second. This is some one else's form that he has reached his limit of knowledge on and it was passed onto me.
Ill check see if he has locked it or some thing and if he can remember what he named the form unless in the mean time some bright spark can give me any other routes to finding the forms name.
Re: Fill textbox from command button outlook vba
ok i'll also try and figure it out...
er, one last thing. would it be possible to take a screen shot of your form. you can then delete the picture...
Re: Fill textbox from command button outlook vba
Erm well its a work form not sure they would like it on the net but i can post a pic of the form its based on?
Re: Fill textbox from command button outlook vba
yes you can
and also try this...
double click the textbox in design mode what code do you see?
1 Attachment(s)
Re: Fill textbox from command button outlook vba
Mmmmm form isn't locked by the last guy i dont think i just ran a new one and added a Textbox and commandbutton cant double click that o the controls on it either, maybe its a setting on my outlook.
Picture attached
Re: Fill textbox from command button outlook vba
sorry cant see any picture
Re: Fill textbox from command button outlook vba
Lol sorry you was too fast viewing i took it off to edit was a bit big
Re: Fill textbox from command button outlook vba
after seeing the pic two things that immeadiately came to my mind were...
1) it doesn't look like a form... it looks more like a page
2) Under the view menu, do you have something like "properties window". or select commanbutton and press "F4"...
Re: Fill textbox from command button outlook vba
Nope neither Maybe because its based on a template in the file system it has limited facility i can certainly add textboxs, buttons, lables, frames ect and as i said i can display a msgbog with the code in the Cmd1_click event it does not want to recognise the other controls i even tried setting the command buttons caption again object missing. very strange.
Re: Fill textbox from command button outlook vba
My mind suddenly has gone blank...
Maybe I should stay away from Outlook VBA :lol:
Let me see if i can find an answer for you...
Re: Fill textbox from command button outlook vba
Lol thanks for your help i am sure this is some thing simple but can't for the life of me find out what.
Re: Fill textbox from command button outlook vba
yeah
even i think so....
Anyways I am having a look at http://www.outlookcode.com
see if that helps you...
Re: Fill textbox from command button outlook vba
\o/ found it bloody long winded though
Code:
Item.GetInspector.ModifiedFormPages("P.2").TextBox1.value = "TEST"
Thanks Koolsid
Re: Fill textbox from command button outlook vba
hURRAY!!!!!
I learnt something about outlook vba today :)