Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Filesystemobject Help

I am trying to add files to a folder that already exist,which was working
fine until I found out the the folder name was not TAPECOMPARE,but is Tape
Tracking 05-2005. I have coded strFolder = Left(strfile, Len(strFile
-2),which will remove the date portion of the folder to only show the month.
Now how do I get the month,dash and year to all show up for that folder. Will
I have to hardcode the year in when it changes. The code I am using is listed
below:

Private Sub cmdDone_Click()
Const cstrpath As String = "C:\Documents and Settings\Owner\My Documents\"
Dim fso As Scripting.FileSystemObject
Dim fld As Scripting.Folder
Dim strFile As String
Dim strDate As String
Dim strFolder As String
Dim wkb As Excel.Workbook

strFile = "TapeCompare"
strFile = strFile & Replace(Me.txtFileNameDate, " ", "")
strFolder = Left(strFile, Len(strFile) - 2)
Set fso = New Scripting.FileSystemObject
If Not fso.FolderExists(cstrpath & strFolder) Then
MkDir (cstrpath & strFolder)
End If
'Set fld = fso.GetFolder(cstrpath & strFolder)
Set wkb = Excel.ActiveWorkbook
wkb.SaveAs cstrpath & strFolder & "\" & strFile & ".xls"
'wkb.SaveAs cstrpath & "Cynthia Grover.xls"

MsgBox "file has been Saved As: " & wkb.Name & "In Folder" & cstrpath &
strFolder
Set wkb = Nothing
Unload Me

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Filesystemobject Help

What does me.TextFileNameDate look like?

--
Regards,
Tom Ogilvy




"CyndyG" wrote in message
...
I am trying to add files to a folder that already exist,which was working
fine until I found out the the folder name was not TAPECOMPARE,but is Tape
Tracking 05-2005. I have coded strFolder = Left(strfile, Len(strFile
-2),which will remove the date portion of the folder to only show the

month.
Now how do I get the month,dash and year to all show up for that folder.

Will
I have to hardcode the year in when it changes. The code I am using is

listed
below:

Private Sub cmdDone_Click()
Const cstrpath As String = "C:\Documents and Settings\Owner\My

Documents\"
Dim fso As Scripting.FileSystemObject
Dim fld As Scripting.Folder
Dim strFile As String
Dim strDate As String
Dim strFolder As String
Dim wkb As Excel.Workbook

strFile = "TapeCompare"
strFile = strFile & Replace(Me.txtFileNameDate, " ", "")
strFolder = Left(strFile, Len(strFile) - 2)
Set fso = New Scripting.FileSystemObject
If Not fso.FolderExists(cstrpath & strFolder) Then
MkDir (cstrpath & strFolder)
End If
'Set fld = fso.GetFolder(cstrpath & strFolder)
Set wkb = Excel.ActiveWorkbook
wkb.SaveAs cstrpath & strFolder & "\" & strFile & ".xls"
'wkb.SaveAs cstrpath & "Cynthia Grover.xls"

MsgBox "file has been Saved As: " & wkb.Name & "In Folder" & cstrpath &
strFolder
Set wkb = Nothing
Unload Me

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Filesystemobject Help

me.txtFileNameDate will end of looking like this afet the user key in the
month and date on the userform....TapeCompar0515 ,that will go in the Tape
Tracking folder. Here is that procedure :
Private Sub cmdSaveFileName_Click()
Dim wkb As Excel.Workbook
Set wkb = Excel.ActiveWorkbook
'strWork = Right(wkb.Name, 17)
If Left(wkb.Name, 11) = "TapeCompare" And IsNumeric(Mid(wkb.Name, 12, 4))
And Len(wkb.Name) = 19 Then
wkb.Save
Else
Load FileNameAndDate
FileNameAndDate!txtFileNameDate.SelStart = 0
FileNameAndDate!txtFileNameDate.SelLength =
Len(FileNameAndDate.txtFileNameDate)
FileNameAndDate.Show
End If

Set wkb = Nothing

End Sub
"Tom Ogilvy" wrote:

What does me.TextFileNameDate look like?

--
Regards,
Tom Ogilvy




"CyndyG" wrote in message
...
I am trying to add files to a folder that already exist,which was working
fine until I found out the the folder name was not TAPECOMPARE,but is Tape
Tracking 05-2005. I have coded strFolder = Left(strfile, Len(strFile
-2),which will remove the date portion of the folder to only show the

month.
Now how do I get the month,dash and year to all show up for that folder.

Will
I have to hardcode the year in when it changes. The code I am using is

listed
below:

Private Sub cmdDone_Click()
Const cstrpath As String = "C:\Documents and Settings\Owner\My

Documents\"
Dim fso As Scripting.FileSystemObject
Dim fld As Scripting.Folder
Dim strFile As String
Dim strDate As String
Dim strFolder As String
Dim wkb As Excel.Workbook

strFile = "TapeCompare"
strFile = strFile & Replace(Me.txtFileNameDate, " ", "")
strFolder = Left(strFile, Len(strFile) - 2)
Set fso = New Scripting.FileSystemObject
If Not fso.FolderExists(cstrpath & strFolder) Then
MkDir (cstrpath & strFolder)
End If
Set wkb = Excel.ActiveWorkbook
wkb.SaveAs cstrpath & strFolder & "\" & strFile & ".xls"
MsgBox "file has been Saved As: " & wkb.Name & "In Folder" & cstrpath &
strFolder
Set wkb = Nothing
Unload Me

End Sub




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Filesystemobject Help

Your trying to turn

TapeCompar0515

into

Tape Tracking 05-2005

???



I assume the 05 in the first is the month. How do you intend to determine
the year?

If this is what you are doing:

s = "TapeCompar0515"
strFile = strFile & Replace(s, " ", "")
? strFile
TapeCompar0515
strFolder = Left(strFile, Len(strFile) - 2)
? strFolder
TapeCompar05

then to change strFolder to Tape Tracking 05-

strFolder = Replace(strFolder,"TapeCompar","Tape Tracking")

strFolder = Replace(strFolder,"TapeCompar","Tape Tracking")
? strFolder
Tape Tracking05

Then you append

strFolder = strFolder & "-" & year(date)

modify year(date) to a method that will produce the proper year.

--
Regards,
Tom Ogilvy






--
Regards,
Tom Ogilvy


"CyndyG" wrote in message
...
me.txtFileNameDate will end of looking like this afet the user key in the
month and date on the userform....TapeCompar0515 ,that will go in the Tape
Tracking folder. Here is that procedure :
Private Sub cmdSaveFileName_Click()
Dim wkb As Excel.Workbook
Set wkb = Excel.ActiveWorkbook
'strWork = Right(wkb.Name, 17)
If Left(wkb.Name, 11) = "TapeCompare" And IsNumeric(Mid(wkb.Name, 12, 4))
And Len(wkb.Name) = 19 Then
wkb.Save
Else
Load FileNameAndDate
FileNameAndDate!txtFileNameDate.SelStart = 0
FileNameAndDate!txtFileNameDate.SelLength =
Len(FileNameAndDate.txtFileNameDate)
FileNameAndDate.Show
End If

Set wkb = Nothing

End Sub
"Tom Ogilvy" wrote:

What does me.TextFileNameDate look like?

--
Regards,
Tom Ogilvy




"CyndyG" wrote in message
...
I am trying to add files to a folder that already exist,which was

working
fine until I found out the the folder name was not TAPECOMPARE,but is

Tape
Tracking 05-2005. I have coded strFolder = Left(strfile, Len(strFile
-2),which will remove the date portion of the folder to only show the

month.
Now how do I get the month,dash and year to all show up for that

folder.
Will
I have to hardcode the year in when it changes. The code I am using is

listed
below:

Private Sub cmdDone_Click()
Const cstrpath As String = "C:\Documents and Settings\Owner\My

Documents\"
Dim fso As Scripting.FileSystemObject
Dim fld As Scripting.Folder
Dim strFile As String
Dim strDate As String
Dim strFolder As String
Dim wkb As Excel.Workbook

strFile = "TapeCompare"
strFile = strFile & Replace(Me.txtFileNameDate, " ", "")
strFolder = Left(strFile, Len(strFile) - 2)
Set fso = New Scripting.FileSystemObject
If Not fso.FolderExists(cstrpath & strFolder) Then
MkDir (cstrpath & strFolder)
End If
Set wkb = Excel.ActiveWorkbook
wkb.SaveAs cstrpath & strFolder & "\" & strFile & ".xls"
MsgBox "file has been Saved As: " & wkb.Name & "In Folder" & cstrpath

&
strFolder
Set wkb = Nothing
Unload Me

End Sub






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Filesystemobject Help

Thank You.

"Tom Ogilvy" wrote:

Your trying to turn

TapeCompar0515

into

Tape Tracking 05-2005

???



I assume the 05 in the first is the month. How do you intend to determine
the year?

If this is what you are doing:

s = "TapeCompar0515"
strFile = strFile & Replace(s, " ", "")
? strFile
TapeCompar0515
strFolder = Left(strFile, Len(strFile) - 2)
? strFolder
TapeCompar05

then to change strFolder to Tape Tracking 05-

strFolder = Replace(strFolder,"TapeCompar","Tape Tracking")

strFolder = Replace(strFolder,"TapeCompar","Tape Tracking")
? strFolder
Tape Tracking05

Then you append

strFolder = strFolder & "-" & year(date)

modify year(date) to a method that will produce the proper year.

--
Regards,
Tom Ogilvy






--
Regards,
Tom Ogilvy


"CyndyG" wrote in message
...
me.txtFileNameDate will end of looking like this afet the user key in the
month and date on the userform....TapeCompar0515 ,that will go in the Tape
Tracking folder. Here is that procedure :
Private Sub cmdSaveFileName_Click()
Dim wkb As Excel.Workbook
Set wkb = Excel.ActiveWorkbook
'strWork = Right(wkb.Name, 17)
If Left(wkb.Name, 11) = "TapeCompare" And IsNumeric(Mid(wkb.Name, 12, 4))
And Len(wkb.Name) = 19 Then
wkb.Save
Else
Load FileNameAndDate
FileNameAndDate!txtFileNameDate.SelStart = 0
FileNameAndDate!txtFileNameDate.SelLength =
Len(FileNameAndDate.txtFileNameDate)
FileNameAndDate.Show
End If

Set wkb = Nothing

End Sub
"Tom Ogilvy" wrote:

What does me.TextFileNameDate look like?

--
Regards,
Tom Ogilvy




"CyndyG" wrote in message
...
I am trying to add files to a folder that already exist,which was

working
fine until I found out the the folder name was not TAPECOMPARE,but is

Tape
Tracking 05-2005. I have coded strFolder = Left(strfile, Len(strFile
-2),which will remove the date portion of the folder to only show the
month.
Now how do I get the month,dash and year to all show up for that

folder.
Will
I have to hardcode the year in when it changes. The code I am using is
listed
below:

Private Sub cmdDone_Click()
Const cstrpath As String = "C:\Documents and Settings\Owner\My
Documents\"
Dim fso As Scripting.FileSystemObject
Dim fld As Scripting.Folder
Dim strFile As String
Dim strDate As String
Dim strFolder As String
Dim wkb As Excel.Workbook

strFile = "TapeCompare"
strFile = strFile & Replace(Me.txtFileNameDate, " ", "")
strFolder = Left(strFile, Len(strFile) - 2)
Set fso = New Scripting.FileSystemObject
If Not fso.FolderExists(cstrpath & strFolder) Then
MkDir (cstrpath & strFolder)
End If
Set wkb = Excel.ActiveWorkbook
wkb.SaveAs cstrpath & strFolder & "\" & strFile & ".xls"
MsgBox "file has been Saved As: " & wkb.Name & "In Folder" & cstrpath

&
strFolder
Set wkb = Nothing
Unload Me

End Sub







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
filesystemobject Alvin Hansen[_2_] Excel Programming 2 February 16th 05 03:47 PM
filesystemobject Alvin Hansen[_2_] Excel Programming 3 January 27th 05 06:17 PM
Help using FileSystemObject CopyFile Tod Excel Programming 1 May 12th 04 10:18 PM
FileSystemObject lol[_2_] Excel Programming 2 April 6th 04 09:56 PM
Help with FileSystemObject? Ed[_9_] Excel Programming 2 August 5th 03 12:08 AM


All times are GMT +1. The time now is 04:31 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"