Vb6 Object required error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Wernerh
    New Member
    • Jul 2007
    • 104

    Vb6 Object required error

    Hi, please could you tell me where i have gone wrong to get this error.

    VB6 code


    Dim fso As New FileSystemObjec t
    Dim f As file
    Set f = fso.getFile(App .Path & "\" & "\data\adodb1.m db")
    FileSystemObjec t.CopyFile App.Path & "\" & "\data\adodb1.m db", App.Path & "\" & "\data\adodb2.m db"

    Thank you
  • mafaisal
    New Member
    • Sep 2007
    • 142

    #2
    Hello
    Here
    Set f = fso.getFile(App .Path & "\" & "\data\adodb1.m db") change
    to
    Set f = fso.getFile(App .Path & "\data\adodb1.m db")

    ie i think one "\" is excess try
    also
    next line avoide excess "\"

    Faisal

    Originally posted by Wernerh
    Hi, please could you tell me where i have gone wrong to get this error.

    VB6 code


    Dim fso As New FileSystemObjec t
    Dim f As file
    Set f = fso.getFile(App .Path & "\" & "\data\adodb1.m db")
    FileSystemObjec t.CopyFile App.Path & "\" & "\data\adodb1.m db", App.Path & "\" & "\data\adodb2.m db"

    Thank you

    Comment

    • Wernerh
      New Member
      • Jul 2007
      • 104

      #3
      Originally posted by mafaisal
      Hello
      Here
      Set f = fso.getFile(App .Path & "\" & "\data\adodb1.m db") change
      to
      Set f = fso.getFile(App .Path & "\data\adodb1.m db")

      ie i think one "\" is excess try
      also
      next line avoide excess "\"

      Faisal
      Hi Faisal,

      I have done the changes and still have the same "error 424 Object required" :-<<

      Please check again for me.

      Thanks
      Werner

      Comment

      • Wernerh
        New Member
        • Jul 2007
        • 104

        #4
        Originally posted by Wernerh
        Hi Faisal,

        I have done the changes and still have the same "error 424 Object required" :-<<

        Please check again for me.

        Thanks
        Werner
        Herewith the changed code;

        Dim fso As New FileSystemObjec t
        Dim F As File
        Set F = fso.GetFile(App .Path & "\data\adodb1.m db")
        FileSystemObjec t.CopyFile App.Path & "\data\adodb1.m db", App.Path & "\data\adodb2.m db"

        Thanks
        Werner

        Comment

        • Wernerh
          New Member
          • Jul 2007
          • 104

          #5
          Do I have to declare anything else other than the code posted for this to work?

          Comment

          • mafaisal
            New Member
            • Sep 2007
            • 142

            #6
            Hello

            Try This

            Dim F1,F2 as string
            Dim FSO As New FileSystemObjec t
            F1 = App.Path & "\data\adodb1.m db"
            F2 = App.Path & "\data\adodb2.m db"
            FSO.CopyFile F1,F2,True

            Use Object of Filesystemobjec t
            Faisal

            Comment

            • Wernerh
              New Member
              • Jul 2007
              • 104

              #7
              Originally posted by mafaisal
              Hello

              Try This

              Dim F1,F2 as string
              Dim FSO As New FileSystemObjec t
              F1 = App.Path & "\data\adodb1.m db"
              F2 = App.Path & "\data\adodb2.m db"
              FSO.CopyFile F1,F2,True

              Use Object of Filesystemobjec t
              Faisal
              Thanks Faisal, you are a star. It works perfectly now.

              Cheers
              Werner

              Comment

              • Ali Rizwan
                Banned
                Contributor
                • Aug 2007
                • 931

                #8
                For copying process you can do a simple code instead of doing all this.

                CopyFile(Path,P ath)

                if you got error then try FileCopy. I have doubt between Copyfile and filecopy.

                This will create a duplicate of original file where you want.

                Regards
                >> ALI <<

                Comment

                • mafaisal
                  New Member
                  • Sep 2007
                  • 142

                  #9
                  Hello,
                  Always Wlecome
                  Thanx


                  Originally posted by Wernerh
                  Thanks Faisal, you are a star. It works perfectly now.

                  Cheers
                  Werner

                  Comment

                  Working...