Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Syntax and compile error.
I am getting a syntax and compile error on the dim cou .... line. Any suggestions? Thanks, Jim Sub createfolders() ' ' dim cou as integer,Dim FolderStr as string, FileSys For cou = 1 To ActiveSheet.UsedRange.Rows.Count FolderStr = Format(Trim(Str(cou)), "00#") + "_" + ActiveSheet.Cells(cou, 1) Set FileSys = CreateObject("Scripting.FileSystemObject") FileSys.createfolder C:\ + RESERVES Next End Sub -- Jim15 ------------------------------------------------------------------------ Jim15's Profile: http://www.excelforum.com/member.php...o&userid=26300 View this thread: http://www.excelforum.com/showthread...hreadid=526198 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Syntax and compile error.
While you can Dim more than one variable on a line of code, you
need to use only a single Dim keyword. Change dim cou as integer,Dim FolderStr as string, FileSys to dim cou as integer, FolderStr as string, FileSys -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Jim15" wrote in message ... I am getting a syntax and compile error on the dim cou .... line. Any suggestions? Thanks, Jim Sub createfolders() ' ' dim cou as integer,Dim FolderStr as string, FileSys For cou = 1 To ActiveSheet.UsedRange.Rows.Count FolderStr = Format(Trim(Str(cou)), "00#") + "_" + ActiveSheet.Cells(cou, 1) Set FileSys = CreateObject("Scripting.FileSystemObject") FileSys.createfolder C:\ + RESERVES Next End Sub -- Jim15 ------------------------------------------------------------------------ Jim15's Profile: http://www.excelforum.com/member.php...o&userid=26300 View this thread: http://www.excelforum.com/showthread...hreadid=526198 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Syntax and compile error.
You can't use dim twice on the same line. Try either of the two following
dim cou as integer Dim FolderStr as string dim FileSys as variant or dim cou as integer, FolderStr as string, FileSys -- HTH... Jim Thomlinson "Jim15" wrote: I am getting a syntax and compile error on the dim cou .... line. Any suggestions? Thanks, Jim Sub createfolders() ' ' dim cou as integer,Dim FolderStr as string, FileSys For cou = 1 To ActiveSheet.UsedRange.Rows.Count FolderStr = Format(Trim(Str(cou)), "00#") + "_" + ActiveSheet.Cells(cou, 1) Set FileSys = CreateObject("Scripting.FileSystemObject") FileSys.createfolder C:\ + RESERVES Next End Sub -- Jim15 ------------------------------------------------------------------------ Jim15's Profile: http://www.excelforum.com/member.php...o&userid=26300 View this thread: http://www.excelforum.com/showthread...hreadid=526198 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Syntax and compile error.
Dim Cou As Long: Dim foldersys As String: Dim filesys As Variant
But that's way too ugly for even me. Jim Thomlinson wrote: You can't use dim twice on the same line. Try either of the two following dim cou as integer Dim FolderStr as string dim FileSys as variant or dim cou as integer, FolderStr as string, FileSys -- HTH... Jim Thomlinson "Jim15" wrote: I am getting a syntax and compile error on the dim cou .... line. Any suggestions? Thanks, Jim Sub createfolders() ' ' dim cou as integer,Dim FolderStr as string, FileSys For cou = 1 To ActiveSheet.UsedRange.Rows.Count FolderStr = Format(Trim(Str(cou)), "00#") + "_" + ActiveSheet.Cells(cou, 1) Set FileSys = CreateObject("Scripting.FileSystemObject") FileSys.createfolder C:\ + RESERVES Next End Sub -- Jim15 ------------------------------------------------------------------------ Jim15's Profile: http://www.excelforum.com/member.php...o&userid=26300 View this thread: http://www.excelforum.com/showthread...hreadid=526198 -- Dave Peterson |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Syntax and compile error.
I am getting a compile error on the C: RESERVES saying "function not defined". I want to create a folder called C:\RESERVES on my hard drive and subfolders with what is in column A on my Excel spreadsheet. We're almost there! Thanks, Jim Sub createfolders() ' ' CreateFolders Macro ' Macro recorded 3/22/2006 by JBW ' Dim cou As Integer, FolderStr As String, FileSys For cou = 1 To ActiveSheet.UsedRange.Rows.Count FolderStr = Format(Trim(Str(cou)), "00#") + "_" + ActiveSheet.Cells(cou, 1) Set FileSys = CreateObject("Scripting.FileSystemObject") FileSys.createfolder C: RESERVES Next End Sub -- Jim15 ------------------------------------------------------------------------ Jim15's Profile: http://www.excelforum.com/member.php...o&userid=26300 View this thread: http://www.excelforum.com/showthread...hreadid=526198 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Syntax and compile error.
Replace
FileSys.createfolder C: RESERVES with FileSys.createfolder "C:\RESERVES" -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Jim15" wrote in message ... I am getting a compile error on the C: RESERVES saying "function not defined". I want to create a folder called C:\RESERVES on my hard drive and subfolders with what is in column A on my Excel spreadsheet. We're almost there! Thanks, Jim Sub createfolders() ' ' CreateFolders Macro ' Macro recorded 3/22/2006 by JBW ' Dim cou As Integer, FolderStr As String, FileSys For cou = 1 To ActiveSheet.UsedRange.Rows.Count FolderStr = Format(Trim(Str(cou)), "00#") + "_" + ActiveSheet.Cells(cou, 1) Set FileSys = CreateObject("Scripting.FileSystemObject") FileSys.createfolder C: RESERVES Next End Sub -- Jim15 ------------------------------------------------------------------------ Jim15's Profile: http://www.excelforum.com/member.php...o&userid=26300 View this thread: http://www.excelforum.com/showthread...hreadid=526198 |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Syntax and compile error.
Thanks. I am now getting an error that says "File already exists". The routine is creating a folder called C:\RESERVES but not creating the subfolders. I have the letters A - O in rows 1 - 15 of the Excel spreadsheet but it is not creating those subfolders in RESERVES. Jim -- Jim15 ------------------------------------------------------------------------ Jim15's Profile: http://www.excelforum.com/member.php...o&userid=26300 View this thread: http://www.excelforum.com/showthread...hreadid=526198 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
compile/syntax error to save active book to new location on networ | Excel Worksheet Functions | |||
VBAProject name compile error, not defined at compile time | Excel Programming | |||
Need Help with Programming-Syntax/Compile Errors | Excel Programming | |||
VLOOKUP Compile/Syntax Error | Excel Programming |