Using ADO Record to Create and Navigate Intranet Files and Folders - Creating files (Page 3 of 6 )
Just as you created the folders, you can create files. While reviewing the earlier suggested links you might have learned the difference between a folder and a file. The folder is a container of files, whereas the file has to stand by itself. In other words the file is a non-collection type in the parlance of ADO.
Add a form in design and add the following code to the click event of the button.
Private Sub Command0_Click()
Set rec = New ADODB.Record
'Open the DevHome/AspFree folder
rec.Open "DevHome/ASPFree", _
"URL=http://hodentek/", , _
adCreateOverwrite + adCreateCollection
rec.Close
'create a Test.htm file in the ASPFree folder
rec.Open "DevHome/ASPFree/Test.htm", _
"URL=http://hodentek/", , _
adCreateOverwrite + adCreateNonCollection
rec.Close
'create a Test.xls file in the ASPFree folder
rec.Open "DevHome/ASPFree/Test.xls", _
"URL=http://hodentek/", , _
adCreateOverwrite + adCreateNonCollection
rec.Close
'create a Test.BMP file in the ASPFree folder
rec.Open "DevHome/ASPFree/Test.bmp", _
"URL=http://hodentek/", , _
adCreateOverwrite + adCreateNonCollection
rec.Close
'create a Test.aspx file in the ASPFree folder
rec.Open "DevHome/ASPFree/Test.aspx", _
"URL=http://hodentek/", , _
adCreateOverwrite + adCreateNonCollection
rec.Close
'adCreateOverwrite and adCreateNonCollection etc can be added
End Sub
ADO objects are rich in enum constants; it will be useful if you can verify what they mean by going to the Object Browser. Here is one example, shown in the next picture.

Next: Adding files to folders >>
More Database Articles
More By Jayaram Krishnaswamy