Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Using a TextBox value in a file String

I have the following code ina standard module, the user can enter there own
file name via a form.

Sub The_SubSave()
Dim fName As String
fName = frmOptions.TextBox1.Value
If frmOptions.CheckBox2.Value = False Then
ActiveWorkbook.SaveCopyAs "C:\AutoSaves" & "fName" _
& "." & Format(Date, "dd-mmm-yyyy") & "." & Format(Time, "hh-mm-ss") &
".xls"
Else
ActiveWorkbook.SaveCopyAs "C:\AutoSaves\DDE Sheet" _
& "." & Format(Date, "dd-mmm-yyyy") & "." & Format(Time, "hh-mm-ss") &
".xls"
End If
StartTimer

End Sub

The problem is if the checkbox is false the first if statement which include
the textbox value as part if the file path does'nt work.

Ive trie placing in( ) and " " of having the tectbox in the string but it
does not wok!
The Else option works fine!
Does anyone have any suggestions

Thanks in advance for any help
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Using a TextBox value in a file String

Hi
fName is already a string so you want to use fName not "fName"
You also have a periods (.) in the middle of your strings , as well as
the one in front of your xls at the end. This is a file name no no so
you should remove them.
regards
Paul

On Mar 9, 11:49 am, Mark Dullingham
wrote:
I have the following code ina standard module, the user can enter there own
file name via a form.

Sub The_SubSave()
Dim fName As String
fName = frmOptions.TextBox1.Value
If frmOptions.CheckBox2.Value = False Then
ActiveWorkbook.SaveCopyAs "C:\AutoSaves" & "fName" _
& "." & Format(Date, "dd-mmm-yyyy") & "." & Format(Time, "hh-mm-ss") &
".xls"
Else
ActiveWorkbook.SaveCopyAs "C:\AutoSaves\DDE Sheet" _
& "." & Format(Date, "dd-mmm-yyyy") & "." & Format(Time, "hh-mm-ss") &
".xls"
End If
StartTimer

End Sub

The problem is if the checkbox is false the first if statement which include
the textbox value as part if the file path does'nt work.

Ive trie placing in( ) and " " of having the tectbox in the string but it
does not wok!
The Else option works fine!
Does anyone have any suggestions

Thanks in advance for any help



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Using a TextBox value in a file String

Thanks for your reply.

The () in the in the string are there to define the 2 format statements abd
don't appear in the file name.

If called for -

ActiveWorkbook.SaveCopyAs "C:\AutoSaves\DDE Sheet" _
& "." & Format(Date, "dd-mmm-yyyy") & "." & Format(Time, "hh-mm-ss") & ".xls"

Works fine. What I want to do is replace DDE Sheet with the fname , manely
the value of textbox1, but in it's current format it doesn't wor!!
" wrote:

Hi
fName is already a string so you want to use fName not "fName"
You also have a periods (.) in the middle of your strings , as well as
the one in front of your xls at the end. This is a file name no no so
you should remove them.
regards
Paul

On Mar 9, 11:49 am, Mark Dullingham
wrote:
I have the following code ina standard module, the user can enter there own
file name via a form.

Sub The_SubSave()
Dim fName As String
fName = frmOptions.TextBox1.Value
If frmOptions.CheckBox2.Value = False Then
ActiveWorkbook.SaveCopyAs "C:\AutoSaves" & "fName" _
& "." & Format(Date, "dd-mmm-yyyy") & "." & Format(Time, "hh-mm-ss") &
".xls"
Else
ActiveWorkbook.SaveCopyAs "C:\AutoSaves\DDE Sheet" _
& "." & Format(Date, "dd-mmm-yyyy") & "." & Format(Time, "hh-mm-ss") &
".xls"
End If
StartTimer

End Sub

The problem is if the checkbox is false the first if statement which include
the textbox value as part if the file path does'nt work.

Ive trie placing in( ) and " " of having the tectbox in the string but it
does not wok!
The Else option works fine!
Does anyone have any suggestions

Thanks in advance for any help




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Using a TextBox value in a file String

Maybe something like:

ActiveWorkbook.SaveCopyAs "C:\AutoSaves\" & fname & _
& "." & Format(now, "dd-mmm-yyyy.hh-mm-ss") & ".xls"

or (Since I'm confused):

ActiveWorkbook.SaveCopyAs "C:\AutoSaves\" & textbox1.text & _
& "." & Format(now, "dd-mmm-yyyy.hh-mm-ss") & ".xls"

(I changed the date and time to now, too.)

Mark Dullingham wrote:

Thanks for your reply.

The () in the in the string are there to define the 2 format statements abd
don't appear in the file name.

If called for -

ActiveWorkbook.SaveCopyAs "C:\AutoSaves\DDE Sheet" _
& "." & Format(Date, "dd-mmm-yyyy") & "." & Format(Time, "hh-mm-ss") & ".xls"

Works fine. What I want to do is replace DDE Sheet with the fname , manely
the value of textbox1, but in it's current format it doesn't wor!!
" wrote:

Hi
fName is already a string so you want to use fName not "fName"
You also have a periods (.) in the middle of your strings , as well as
the one in front of your xls at the end. This is a file name no no so
you should remove them.
regards
Paul

On Mar 9, 11:49 am, Mark Dullingham
wrote:
I have the following code ina standard module, the user can enter there own
file name via a form.

Sub The_SubSave()
Dim fName As String
fName = frmOptions.TextBox1.Value
If frmOptions.CheckBox2.Value = False Then
ActiveWorkbook.SaveCopyAs "C:\AutoSaves" & "fName" _
& "." & Format(Date, "dd-mmm-yyyy") & "." & Format(Time, "hh-mm-ss") &
".xls"
Else
ActiveWorkbook.SaveCopyAs "C:\AutoSaves\DDE Sheet" _
& "." & Format(Date, "dd-mmm-yyyy") & "." & Format(Time, "hh-mm-ss") &
".xls"
End If
StartTimer

End Sub

The problem is if the checkbox is false the first if statement which include
the textbox value as part if the file path does'nt work.

Ive trie placing in( ) and " " of having the tectbox in the string but it
does not wok!
The Else option works fine!
Does anyone have any suggestions

Thanks in advance for any help





--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Using a TextBox value in a file String

Dave,

Thanks a million, both your suggestions worked great.

That was the last thing I had to get working on this project and it's been
frustrating me for days.

Thanks for taking the time to reply, much appreciated.

Mark

"Dave Peterson" wrote:

Maybe something like:

ActiveWorkbook.SaveCopyAs "C:\AutoSaves\" & fname & _
& "." & Format(now, "dd-mmm-yyyy.hh-mm-ss") & ".xls"

or (Since I'm confused):

ActiveWorkbook.SaveCopyAs "C:\AutoSaves\" & textbox1.text & _
& "." & Format(now, "dd-mmm-yyyy.hh-mm-ss") & ".xls"

(I changed the date and time to now, too.)

Mark Dullingham wrote:

Thanks for your reply.

The () in the in the string are there to define the 2 format statements abd
don't appear in the file name.

If called for -

ActiveWorkbook.SaveCopyAs "C:\AutoSaves\DDE Sheet" _
& "." & Format(Date, "dd-mmm-yyyy") & "." & Format(Time, "hh-mm-ss") & ".xls"

Works fine. What I want to do is replace DDE Sheet with the fname , manely
the value of textbox1, but in it's current format it doesn't wor!!
" wrote:

Hi
fName is already a string so you want to use fName not "fName"
You also have a periods (.) in the middle of your strings , as well as
the one in front of your xls at the end. This is a file name no no so
you should remove them.
regards
Paul

On Mar 9, 11:49 am, Mark Dullingham
wrote:
I have the following code ina standard module, the user can enter there own
file name via a form.

Sub The_SubSave()
Dim fName As String
fName = frmOptions.TextBox1.Value
If frmOptions.CheckBox2.Value = False Then
ActiveWorkbook.SaveCopyAs "C:\AutoSaves" & "fName" _
& "." & Format(Date, "dd-mmm-yyyy") & "." & Format(Time, "hh-mm-ss") &
".xls"
Else
ActiveWorkbook.SaveCopyAs "C:\AutoSaves\DDE Sheet" _
& "." & Format(Date, "dd-mmm-yyyy") & "." & Format(Time, "hh-mm-ss") &
".xls"
End If
StartTimer

End Sub

The problem is if the checkbox is false the first if statement which include
the textbox value as part if the file path does'nt work.

Ive trie placing in( ) and " " of having the tectbox in the string but it
does not wok!
The Else option works fine!
Does anyone have any suggestions

Thanks in advance for any help




--

Dave Peterson

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
textbox to file (.txt or .doc) Kagan Clearwater Excel Programming 1 November 28th 06 06:07 AM
need to add string to txt file Leech Excel Programming 0 February 7th 06 01:34 PM
HELP! I Lost The Ability To Advance From TextBox To TextBox With the ENTER Or The TAB Keys Minitman[_4_] Excel Programming 0 February 22nd 05 08:50 PM
Retaining value of a string from a textbox on a form ?? Dan Thompson Excel Programming 6 October 28th 04 09:00 PM
Textbox & Save file problem Stuart[_5_] Excel Programming 0 August 4th 04 07:09 PM


All times are GMT +1. The time now is 06:19 AM.

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"