Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Can I do this?

Im in the process of creating a file that a user enters in item numbers and
quantities, runs a macro, and all of the item numbers and planned quantities
pop up on another page showing all testing and sampling information. It also
creates links to other forms used in excel that have testing information and
pay information on it. I creating this form to make running a project easier
and less of a hassle for a user. I want to add something in so when i run a
macro it will go and create a folder with multiple folders therein on a
shared drive, put the needed files in those folders that way it will not have
to be done manualy. Is excel able to create files? I also would like to have
excel make links to these files and link everything up together. Preferably
everything will run off of the one main file. Is this even fesable or am i
wasting my time trying to do this with excel? Would Acess be a better bet for
this? If you can answer any of these questions please do at:

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Can I do this?

You can create folders and files in Excel. Sounds to me like to need to have
a loop for each file. Say you needed a file for each row in a worksheet
which contains one line for each column and a new folder for each worksheet:

HTH,
Gareth

Sub makefiles()
Dim iRow As Long
Dim iCol As Integer
Dim sh As Worksheet
Dim FileNo As Integer
Dim myFileName As String
Dim myRootFolder As String
Dim myCurrentPath As String

myRootFolder = "c:\mydata"
For Each sh In ActiveWorkbook.Sheets
myCurrentPath = myRootFolder & "\" & sh.Name
If Not fcnCheckPathExists(myCurrentPath) Then
MsgBox "Cannot create " & myCurrentPath
Exit Sub
End If

For iRow = 1 To sh.UsedRange.Rows.Count
myFileName = sh.Name & "_ROW" & Format(iRow, "00000") & ".txt"
FileNo = FreeFile
Open myCurrentPath & "\" & myFileName For Output As #FileNo
For iCol = 1 To sh.UsedRange.Columns.Count
Print #FileNo, sh.Cells(iRow, iCol)
Next iCol
Close #FileNo
Next iRow

Next sh

End Sub

''Checks that a path exists and creates it if it doesn't
''Returns False if path cannot be created
Function fcnCheckPathExists(myPath As String) As Boolean

Dim myDrive As String, myCleanPath As String
Dim myFolders As Variant
Dim i As Integer

myCleanPath = Trim(myPath)

'First find out if this is a UNC path or a drive mapping
'Get the drive and rest of the path
If Mid$(myCleanPath, 2, 1) = ":" Then
myDrive = Left$(myCleanPath, 2)
myFolders = Split(Mid$(myCleanPath, 4), "\")
ElseIf Left$(myCleanPath, 2) = "\\" Then
myDrive = "\\" & Mid$(myCleanPath, 3, InStr(3, myCleanPath, "\") - 3)
myFolders = Split(Mid$(myCleanPath, Len(myDrive) + 2), "\")
Else
Exit Function
End If

On Error GoTo Errorhandler
For i = LBound(myFolders) To UBound(myFolders)
myDrive = myDrive & "\" & myFolders(i)
If Dir(myDrive, vbDirectory + vbHidden) = "" Then
MkDir myDrive
End If
Next i

'The path either exists or we successfully created it.
'Hurray! Return true
fcnCheckPathExists = True

Errorhandler:

End Function


"Mike C" wrote in message
...
Im in the process of creating a file that a user enters in item numbers

and
quantities, runs a macro, and all of the item numbers and planned

quantities
pop up on another page showing all testing and sampling information. It

also
creates links to other forms used in excel that have testing information

and
pay information on it. I creating this form to make running a project

easier
and less of a hassle for a user. I want to add something in so when i run

a
macro it will go and create a folder with multiple folders therein on a
shared drive, put the needed files in those folders that way it will not

have
to be done manualy. Is excel able to create files? I also would like to

have
excel make links to these files and link everything up together.

Preferably
everything will run off of the one main file. Is this even fesable or am i
wasting my time trying to do this with excel? Would Acess be a better bet

for
this? If you can answer any of these questions please do at:



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



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