UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Creating A Folder By Fso, Access 2016    
 
   
M2C
post Jul 12 2018, 02:01 AM
Post#1



Posts: 661
Joined: 7-April 08
From: Dubai


Hi
I am trying to create a folder using the following code.

CODE
Private Sub Text27_Click()
Dim FSO
Set FS0 = CreateObject("Scripting.FileSystemObject")
FSO.CreateFolder ("C:\Users\admin\Desktop\Folder2")

End Sub


I have enable the Reference to 'Microsoft Scripting Runtime'

It does not seem to work.

Any ideas?

Thanks
Chris
Go to the top of the page
 
cheekybuddha
post Jul 12 2018, 02:13 AM
Post#2


UtterAccess VIP
Posts: 10,426
Joined: 6-December 03
From: Telegraph Hill


Much easier to use MkDir()
CODE
Private Sub Text27_Click()

  MkDir "C:\Users\admin\Desktop\Folder2"

End Sub

You probably ought to check for the folder's existence before trying to create it.

hth,

d
Go to the top of the page
 
M2C
post Jul 12 2018, 02:26 AM
Post#3



Posts: 661
Joined: 7-April 08
From: Dubai


Indeed it is thanks
Go to the top of the page
 
Phil_cattivocara...
post Jul 12 2018, 03:18 AM
Post#4



Posts: 199
Joined: 2-April 18



As cheekybuddha said, use MkDir.
I write this only for your general knowledge: when you write
CODE
Dim FSO As Object
  Set FS0 = CreateObject("Scripting.FileSystemObject")
you do not need Reference to 'Microsoft Scripting Runtime'. This is called "latebinding". Note "As Object" added in FSO declaration.
This post has been edited by Phil_cattivocarattere: Jul 12 2018, 03:18 AM
Go to the top of the page
 
M2C
post Jul 12 2018, 03:51 AM
Post#5



Posts: 661
Joined: 7-April 08
From: Dubai


Thanks Phil
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    15th October 2018 - 07:45 AM