View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
CyndyG CyndyG is offline
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