Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I have this code and I want it to open a file in a directory that I choose (it does that already), and then I wunt it to create a sub-folder in the folder I chose with the original folders name plus a number. (example) I choose a folder named project_test then it converts the file, in the folder, detail.htm to detail.htm.wk4. Then it creates the sub-folder project_test0001 then saves detail.htm.wk4 in it. Then the next time I run ConvertFiles ,when it creates the sub-folder, it creates project_test0002, and when it has reached the tenth time it creates it as project_test0010 etc. Code: -------------------- Sub ConvertFiles() ' ' Application.DisplayAlerts = False ' Dim vrtSelectedItem As Variant Dim FileToOpen As String 'Declare a variable as a FileDialog object. Dim fd As FileDialog Set fd = Application.FileDialog(msoFileDialogFolderPicker) fd.Title = "Cool Application" fd.InitialFileName = "Working" If fd.Show = -1 Then For a = 1 To fd.SelectedItems.Count MsgBox fd.SelectedItems(a) Dim NextFile As String NextFile = Dir(fd.SelectedItems(a) & "\*detail*.htm") Do While NextFile < "" Workbooks.Open Filename:=NextFile ActiveWorkbook.SaveAs Filename:= _ NextFile & ".wk4", _ FileFormat:=xlWK4, Password:="", WriteResPassword:="", _ ReadOnlyRecommended:=False, CreateBackup:=False ActiveWorkbook.Save ActiveWorkbook.Close NextFile = Dir() Loop Next End If Application.DisplayAlerts = True End Sub -------------------- -- tim64 ------------------------------------------------------------------------ tim64's Profile: http://www.excelforum.com/member.php...o&userid=23295 View this thread: http://www.excelforum.com/showthread...hreadid=379459 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
open and save an entire folder | Excel Discussion (Misc queries) | |||
can“t change folder when open or save | Excel Discussion (Misc queries) | |||
Need code to save file to new folder, erase from old folder | Excel Discussion (Misc queries) | |||
"Save As" folder -- can I default this to the same folder as origi | Excel Discussion (Misc queries) | |||
I like to open a folder,auto print,save then close | Excel Programming |