ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   TextBox Coding Help (https://www.excelbanter.com/excel-programming/274806-re-textbox-coding-help.html)

Shauna Koppang

TextBox Coding Help
 
HI Tom,

Thanks SO much for your reply. In the interim I got just about as far
as you described. I can get it to display when I run it but not when I
File menu, New and create a new workbook based on my template.

Here is the code so far:

In Module 1:
Sub ShowForm()
UserForm1.Show
End Sub

In UserForm:
Private Sub CommandButton1_Click()

'Insert text from textboxes into cells
With ActiveDocument
Worksheets("Sheet1").Range("A1") = TextBox1.Text
Worksheets("Sheet1").Range("A3") = TextBox2.Text

End With

UserForm1.Hide

End Sub
It works and enters the values into the cells but I can't get it to
launch the userform when I File menu, New, choose the templates and
click OK.

Any hints?

THANKS SO MUCH!!! Next I have to tackle combo boxes as I have to create
a purchase order workbook! Yikes.

Shauna


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Tom Ogilvy

TextBox Coding Help
 
in the vbe, look in the project explorer and find the ThisWorkboook item
under you project. Right click on that and select view code.

In the left dropdown, select workbook
in the right dropdown, select Open

Private Sub Workbook_Open()

End sub

Call you macro i this event - the workbook_open event

Private Sub Workbook_Open()
If ThisWorkbook.Path = "" then
ShowForm
end if
End sub


This event fires when the workbook is opened.

In your code, you don't need

With ActiveDocument


End With

1) you don't use it
2) there is no activedocument in Excel - this is a Word concept. there is
an activeSheet, but you have specified the sheet already.

--
Regards,
Tom Ogilvy



Shauna Koppang wrote in message
...
HI Tom,

Thanks SO much for your reply. In the interim I got just about as far
as you described. I can get it to display when I run it but not when I
File menu, New and create a new workbook based on my template.

Here is the code so far:

In Module 1:
Sub ShowForm()
UserForm1.Show
End Sub

In UserForm:
Private Sub CommandButton1_Click()

'Insert text from textboxes into cells
With ActiveDocument
Worksheets("Sheet1").Range("A1") = TextBox1.Text
Worksheets("Sheet1").Range("A3") = TextBox2.Text

End With

UserForm1.Hide

End Sub
It works and enters the values into the cells but I can't get it to
launch the userform when I File menu, New, choose the templates and
click OK.

Any hints?

THANKS SO MUCH!!! Next I have to tackle combo boxes as I have to create
a purchase order workbook! Yikes.

Shauna


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!




Shauna Koppang

TextBox Coding Help
 

Hi Tom,

Again THANKS SO MUCH for your help. Got it working now. My next task
today is to develop a listbox or ComboBox that then links to a VLookup
table in the same workbook on another sheet. I remember glimpsing some
coding in my search for text box coding. Any hints on this or where to
look?

I will dilligently be searching for this coding this morning. Just for
a background I have been given a project to create a combination
Purchase Order/Accounts Payable Voucher workbook where the purchasing
agent fills in most of the information on the Purchase order and it
links to fields in the AP Voucher. Lots of pick lists and VLookup tables
which I can do, but they would like it automated with a Userform to help
the fill-in process. Hence my struggles... particularly seeing I an a
rank VB beginner. So thanks for your patience:-)

Shauna


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com