LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Creating a folder using Visual Basic HELP!!!

Dim ExistingFolderName as string
Dim NewFolderName as string

existingfoldername = "I:\SW\users\CR Prioritization\Automation Test Folder"
if right(existingfoldername, 1) < "\" then
existingfoldername = existingfoldername & "\"
end if

'no slashes in that date format!
newfoldername = existingfoldername & format(date,"yyyy_mm_dd")

on error resume next 'in case the folder can't be made
mkdir newfoldername
if err.number < 0 then
msgbox "error creating folder!"
err.clear
end if



DanMsoeEE wrote:

I'm very new to visual basic and I was wondering how do I create a folder and
place the modified file from the macro into that new folder. Here's my code
so far. I would also like to name the folder and file to they day that the
macro is run if that's possible?

Option Explicit

Sub CRautomate()

'Application.OnTime TimeValue("012:49:00"), "CRautomate"

'-----------Declare all variables-----
Dim Col As Integer
Dim Row As Integer

Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object

Dim newBook As Workbook
Dim newSheet As Worksheet

Workbooks.Open "I:\SW\users\CR Prioritization\Raw Data\template" 'Open
template file with dropdown menus

'--------Populate the spreadsheet----------------------------
Row = 1
Do Until Row = 25

For Col = 1 To 35
ActiveSheet.Cells(Row, Col) = Data.Cells((8 + Row), Col).Value

Next
Row = Row + 1
If Row = 2 Then Row = 3 'gets rid of .... field

Loop

ActiveSheet.Columns("B:D").Hidden = False 'unhide columns
ActiveSheet.Columns("D:D").ColumnWidth = 20 'make column D visible
ActiveSheet.Rows(2).Delete

With Application.FileSearch
.NewSearch
.FileType = msoFileTypeExcelWorkbooks
.LookIn = "I:\SW\users\CR Prioritization"
.SearchSubFolders = True
End With




ActiveSheet.SaveAs "I:\SW\users\CR Prioritization\Automation Test
Folder\Open CR List" 'output file

Workbooks("Open CR List.xls").Close 'close the file which was opened

End Sub


--

Dave Peterson
 
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
Creating a Visual Basic Macro Clarence Excel Discussion (Misc queries) 1 March 24th 10 08:06 PM
explanation of codes in Visual Basic when creating User form Rachel New Users to Excel 2 November 4th 09 11:19 PM
Can I run Visual Basic procedure using Excel Visual Basic editor? john.jacobs71[_2_] Excel Programming 3 December 26th 05 02:22 PM
Creating Toolbar on Word 2000 using built-in Visual Basic Editor Sagar Gadre Excel Programming 1 September 10th 04 02:19 PM
creating Toolbar on Word 2000 using built-in Visual Basic Editor sagarsehwag Excel Programming 0 August 22nd 04 02:22 PM


All times are GMT +1. The time now is 11:13 AM.

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

About Us

"It's about Microsoft Excel"