Unanswered Move folders from a sharepoint to local system.

  • Sunday, April 22, 2012 8:39 AM
     
     

    Hi everyone.....

    Plz,,,,,,,,,,,help me with the vba code if you can,,,,,,,,,

    I have to copy files/folders from a general share point to the local system....

    So if i give the path of the share point and path of the folder in the local system then it has to copy all the folders/files and paste it the local system..........

    Plz.....help me this out.......


    Veeru

All Replies

  • Sunday, April 22, 2012 8:47 AM
     
     

    A sharepoint folder is encrypted stored in an SQL DataBase. 

    Be aware this is a forum for VB which is in Visual Studio Net. 

    However, I've doubt that you get help in the VBA forum, probably a Sharepoint forum can help you better.

    http://social.msdn.microsoft.com/Forums/en-US/sharepointgeneral/threads


    Success
    Cor

  • Sunday, April 22, 2012 4:07 PM
     
     

    Hi everyone.....

    Plz,,,,,,,,,,,help me with the vba code if you can,,,,,,,,,

    I have to copy files/folders from a general share path(Public folder in office for sharing documents)to the local system....

    So if i give the path of the share path and path of the folder in the local system then it has to copy all the folders/files and paste it the local system..........

    Plz.....help me this out.......


    Veeru

  • Sunday, April 22, 2012 4:24 PM
     
      Has Code

    Your Title says "Move" and the main question says "Copy" - so.........

        Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
            My.Computer.FileSystem.CopyDirectory("d:\source_dir", "e:\dest_dir")
        End Sub
    

    So choose one:

        Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
            My.Computer.FileSystem.MoveDirectory("d:\source_dir", "e:\dest_dir")
        End Sub
    

    be aware that these commands copy/move EVERYTHING, files as well as folders. If you want to only copy/move folders, you will have to enumerate each item in the source path and decide if it qualifies for copying / moving. Or maybe Cor is right and you mean "Sharepoint", in which case ignore this post.

  • Sunday, April 22, 2012 5:20 PM
     
     

    Double post and in this one even wrong stated, in the other post is told that it has noting to with Sharepoint but about moving a file from a public share to a local file using VBA.

    http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/67a53896-888d-4e20-9b59-d68296a12b73#da7dc7e6-6fbb-43d6-b7d0-6085b34bc82b

    So simply a question for this forum.

    http://social.msdn.microsoft.com/Forums/en-US/IsVVBa



    Success
    Cor

  • Sunday, April 22, 2012 5:24 PM
     
     

    This is a forum for VB in Visual Studio net

    This bellow is the forum for VBA  

    http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/d140d438-b45b-4f0c-a00c-238f29bc0154

    But be so clever not to state that it is about Sharepoint, because that information is as much interesting for your question as:

    If the Sharepoint server is about food, if it is about marriage, if it is for kids, if it is for music, if it is for sport, if it is for politics.

    Can be interesting, but persons who are not specialist in that avoid then to answer you.


    Success
    Cor

  • Monday, April 23, 2012 3:56 AM
     
     

    Hi everyone.....

    Plz,,,,,,,,,,,help me with the vba code if you can,,,,,,,,,

    I have to copy files/folders from a general share path(Public folder in office for sharing documents)to the local system....

    So if I give the path of the share path and path of the folder in the local system then it has to copy all the folders/files and paste it the local system..........

    Plz.....help me this out.......


    Veeru

  • Monday, April 23, 2012 4:49 AM
     
     

    Hi Veerusat

    Veerusat wrote:

    I have to copy files/folders from a general share path(Public folder in
    office for sharing documents)to the local system....

    Check the FileCopy comand in the VBA OH

    FileCopy strSourceName, strTargetName

    HTH
    Henry

  • Monday, April 23, 2012 5:30 AM
     
     
     

    Hi Henry Habermacher ,

    The following is the code i tried for copying folders and file from the source path to the destination path.

    But I got an error saying

    "run time error'91'
    Object variable or with block variable not set"

    So my idea is If i specify the path of the source and destination file in the text box then when I click [copy] button it has to copy files and folders from the source path to the destination path.

    Can you help me with this plz............

    Here is my code

    Sub veeru()

    Dim source As Object
    Dim destination As Object
    source = UserForm1.TextBox1.Value
    destination = UserForm1.TextBox2.Value
    Set Fobj = CreateObject("Scripting.FileSystemObject")

    Fobj.CopyFolder "source", "destination"
    End Sub


    Veeru

  • Monday, April 23, 2012 6:32 AM
     
     

    Not sure, what you want to do. Why you create a Scripting.FileSystemObject?

    What application are you using?

    Filecopy should be a direct VBA command. You don't need any other objects.

    Henry

  • Monday, April 23, 2012 7:32 AM
     
     

    Hi Henry Habermacher ,

    Well............That command will be useful for copying files but mi idea is to copy one folder which will contain many sub folders and paste it in my local system.

    To be brief I am going to take a backup of one folder which is present in a public share path.

    So when i specify the paths of source and the destination folder then the system should take a back up of the source folder and paste it in the destination folder.....

    Can you help me ............


    Veeru

  • Monday, April 23, 2012 9:00 AM
     
      Has Code

    ah, ok, understand

    You may try a function lke this one here:

    Public Function copyFolder(strFrom As String, strTo As String)
      Dim fso As Object
      Set fso = CreateObject("Scripting.FileSystemObject")
      fso.copyFolder strFrom, strTo
      Set fso = Nothing
    End Function

    HTH

    Henry


  • Monday, April 23, 2012 9:05 AM
     
      Has Code

    or with your code from above

    Sub veeru()
      Dim source As String
      Dim destination As String
      Dim Fobj As Object
      source = UserForm1.TextBox1.Value
      destination = UserForm1.TextBox2.Value
      Set Fobj = CreateObject("Scripting.FileSystemObject")
      Fobj.CopyFolder source, destination
      Set Fobj = Nothing
    End Sub

    HTH

    Henry

  • Monday, April 23, 2012 11:37 AM
     
     

    Hi Henry Habermacher ,

    Yeah...thanks for your help and I tried with my own understanding and got the output.....

    The same code I used but with few changes....


    Sub veeru()

    Set Fobj = CreateObject("Scripting.FileSystemObject")

    Fobj.CopyFolder UserForm1.TextBox1.Value, UserForm1.TextBox2.Value

    End Sub
    Thanks...Once again...

    But I have a small doubt if you could clear this then it would be great....

    Is it possible to somehow convert this vba code to an executable or a batch file such that if I double clilck the exe/batch file the userform has to appear...


    Veeru

  • Tuesday, April 24, 2012 1:12 AM
     
     

    The above code should run as it is in a .VBS file (Visual Basic Script) that can be run as Batch.

    The only challange you will have is to pass the parameters to the Batch. The batch hardly will be able to read your UserForm, so you will have to pass it to the batch as parameters.

    Henry

  • Tuesday, April 24, 2012 4:57 AM
     
     

    Henry Habermacher wrote:

    The above code should run as it is in a .VBS file (Visual Basic Script)
    that can be run as Batch.

    Here an example (now in the office again):

    create a file called "copyfolder.vbs"

    add following commands inside:

    Option Explicit
    Dim Args
    Dim FromFolder
    Dim ToFolder
    Dim FSO
    Set Args = WScript.Arguments
    FromFolder = Args(0)
    ToFolder = Args(1)
    Set FSO = CreateObject("Scripting.FileSystemObject")
    FSO.CopyFolder FromFolder, ToFolder
    Set FSO = Nothing

    now you can call this file with 2 parameters. The first one is the source folder, the second one the target folder: Let's say you have a folder C:\Temp and want to copy it to C:\Temp2 and the copyfolder.vbs is located in C:\. Then you can send following command in a command prompt window:

    C:\> C:\copyfolder.vbs C:\Temp C:\Temp2

    HTH
    Henry

  • Tuesday, April 24, 2012 6:50 AM
     
     
    I didn't think the FileSystemObject worked with SharePoint, just the Windows file system. My personal experience is that files in SharePoint need individual attention unless there's an add-in around that does this?

    Rod Gill

    The one and only Project VBA Book Rod Gill Project Management