Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel,microsoft.public.excel.programming
|
|||
|
|||
Simple Form: How to copy a value from one object to another?
hello everyone,
There is a simple form in Excel: one button, and one textbox. The button has a CommandButton1_Click() procedure defined as a call to the following subroutine: Public Sub ChooseUniverse() Dim sFile As String sFile = Application.GetOpenFilename(FileFilter:= _ "TXT Files (*.txt), *.txt", FilterIndex:=1, _ Title:="Choose TXT File...") End Sub I tried to figure out if it was possible to pass the sFile value to the textbox so that after choosing a file its path would be visible in the textbox, but I failed at looking for some understandable examples. Does anybody know it is possible and how can be done? I would appreciate any suggestions or hints, or a link to some tutorial (with Excel). thank you, DD ps. Follow-Up To: microsoft.public.excel.programming |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Simple Form: How to copy a value from one object to another?
Not I understand the problem.
How about simply Textbox1.Text = sFile RBS "Dirk Diggler" wrote in message ... hello everyone, There is a simple form in Excel: one button, and one textbox. The button has a CommandButton1_Click() procedure defined as a call to the following subroutine: Public Sub ChooseUniverse() Dim sFile As String sFile = Application.GetOpenFilename(FileFilter:= _ "TXT Files (*.txt), *.txt", FilterIndex:=1, _ Title:="Choose TXT File...") End Sub I tried to figure out if it was possible to pass the sFile value to the textbox so that after choosing a file its path would be visible in the textbox, but I failed at looking for some understandable examples. Does anybody know it is possible and how can be done? I would appreciate any suggestions or hints, or a link to some tutorial (with Excel). thank you, DD ps. Follow-Up To: microsoft.public.excel.programming |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Simple Form: How to copy a value from one object to another?
Dirk, you can do it like the following;
Private Sub CommandButton1_Click() Dim sFile As String sFile = Application.GetOpenFilename(FileFilter:= _ "TXT Files (*.txt), *.txt", FilterIndex:=1, _ Title:="Choose TXT File...") If sFile < "False" Then Me.TextBox1.Text = sFile End If End Sub Bob Flanagan Macro Systems http://www.add-ins.com Productivity add-ins and downloadable books on VB macros for Excel "Dirk Diggler" wrote in message ... hello everyone, There is a simple form in Excel: one button, and one textbox. The button has a CommandButton1_Click() procedure defined as a call to the following subroutine: Public Sub ChooseUniverse() Dim sFile As String sFile = Application.GetOpenFilename(FileFilter:= _ "TXT Files (*.txt), *.txt", FilterIndex:=1, _ Title:="Choose TXT File...") End Sub I tried to figure out if it was possible to pass the sFile value to the textbox so that after choosing a file its path would be visible in the textbox, but I failed at looking for some understandable examples. Does anybody know it is possible and how can be done? I would appreciate any suggestions or hints, or a link to some tutorial (with Excel). thank you, DD ps. Follow-Up To: microsoft.public.excel.programming |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Simple Form: How to copy a value from one object to another?
There are followups in .programming.
Dirk Diggler wrote: hello everyone, There is a simple form in Excel: one button, and one textbox. The button has a CommandButton1_Click() procedure defined as a call to the following subroutine: Public Sub ChooseUniverse() Dim sFile As String sFile = Application.GetOpenFilename(FileFilter:= _ "TXT Files (*.txt), *.txt", FilterIndex:=1, _ Title:="Choose TXT File...") End Sub I tried to figure out if it was possible to pass the sFile value to the textbox so that after choosing a file its path would be visible in the textbox, but I failed at looking for some understandable examples. Does anybody know it is possible and how can be done? I would appreciate any suggestions or hints, or a link to some tutorial (with Excel). thank you, DD ps. Follow-Up To: microsoft.public.excel.programming -- Dave Peterson |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Simple Form: How to copy a value from one object to another?
thank you, guys! I tried to use Value property of TextBox1, and
mistakenly referenced the function. thanks, DD Bob Flanagan wrote: Dirk, you can do it like the following; Private Sub CommandButton1_Click() Dim sFile As String sFile = Application.GetOpenFilename(FileFilter:= _ "TXT Files (*.txt), *.txt", FilterIndex:=1, _ Title:="Choose TXT File...") If sFile < "False" Then Me.TextBox1.Text = sFile End If End Sub |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Simple Form: How to copy a value from one object to another?
Dirk,
This could do the job for you. The subroutine ChooseUniverse I changed in a Function. Private Sub CommandButton1_Click() Dim sFile As Variant sFile = ChooseUniverse If sFile < False Then Me.TextBox1 = sFile Else Me.TextBox1 = Null End If End Sub Public Function ChooseUniverse() As Variant Dim sFile As String sFile = Application.GetOpenFilename(FileFilter:= _ "TXT Files (*.txt), *.txt", FilterIndex:=1, _ Title:="Choose TXT File...") ChooseUniverse = sFile End Function Jan |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Drop-down list on simple excel 2003 form using "form" from data me | Excel Discussion (Misc queries) | |||
Help with simple form | Excel Programming | |||
Help with a simple form | Excel Programming | |||
Help with a simple form | Excel Discussion (Misc queries) | |||
I need a simple PO form | Excel Discussion (Misc queries) |