Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 340
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
jan jan is offline
external usenet poster
 
Posts: 1
Default 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
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
Drop-down list on simple excel 2003 form using "form" from data me S Beals Excel Discussion (Misc queries) 0 March 2nd 10 08:35 PM
Help with simple form SP[_5_] Excel Programming 4 October 28th 05 01:18 PM
Help with a simple form rmcfarron Excel Programming 1 October 4th 05 04:25 PM
Help with a simple form rmcfarron Excel Discussion (Misc queries) 0 October 4th 05 03:59 PM
I need a simple PO form Whosyourdata Excel Discussion (Misc queries) 2 September 28th 05 01:27 AM


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

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

About Us

"It's about Microsoft Excel"