My Documents - path not found

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

    My Documents - path not found

    In vb6 I have the following script:

    FileCopy "C:\My Documents\suppo rt.xls", "C:\Support.xls " - when I run it it returns an error - Path not found.

    When I change it to
    FileCopy "C:\Support.xls ", "C:\Support1.xl s"
    Or any other variation of c:\....... it runs perfectly.

    Is the any reasonable explination why it would not see "c:\My Documents" as a valid drive path??

    Thanks.
  • fplesco
    New Member
    • Jul 2007
    • 82

    #2
    Originally posted by Wernerh
    In vb6 I have the following script:

    FileCopy "C:\My Documents\suppo rt.xls", "C:\Support.xls " - when I run it it returns an error - Path not found.

    When I change it to
    FileCopy "C:\Support.xls ", "C:\Support1.xl s"
    Or any other variation of c:\....... it runs perfectly.

    Is the any reasonable explination why it would not see "c:\My Documents" as a valid drive path??

    Thanks.
    Hi -

    What OS are you using?

    If XP, My Documents is located at

    <D or C>:\Documents and Settings\<Your Windows account name >\My Documents

    to verify the true location of that file. Goto My Documents using Windows Explorer, right-click on the file and then click on Properties. In the File Property pop up dialog, click on General tab and look for its location.

    This way, you can get the exact location of the file.

    Comment

    • Wernerh
      New Member
      • Jul 2007
      • 104

      #3
      Originally posted by fplesco
      Hi -

      What OS are you using?

      If XP, My Documents is located at

      <D or C>:\Documents and Settings\<Your Windows account name >\My Documents

      to verify the true location of that file. Goto My Documents using Windows Explorer, right-click on the file and then click on Properties. In the File Property pop up dialog, click on General tab and look for its location.

      This way, you can get the exact location of the file.

      Thanks for the response
      Hi, yes I am on XP.

      I had done what you suggested and it worked before i posted on the forum, but the problem with that is that if the application is used on another pc, that acount name changes. Is there no way to overcome having to use the account name?

      Thanks

      Comment

      • fplesco
        New Member
        • Jul 2007
        • 82

        #4
        Originally posted by Wernerh
        Thanks for the response
        Hi, yes I am on XP.

        I had done what you suggested and it worked before i posted on the forum, but the problem with that is that if the application is used on another pc, that acount name changes. Is there no way to overcome having to use the account name?

        Thanks
        Okay. Maybe you should have to define a source and destination folder by yourself.

        For example, wherever your file is located, together with that is a source and destination folder.

        And that way, all you have to do is

        FileCopy App.path & "\<source folder>\Support .xls", App.path & "\<destinat ion folder>\Support 1.xls"

        Comment

        • Wernerh
          New Member
          • Jul 2007
          • 104

          #5
          Originally posted by fplesco
          Okay. Maybe you should have to define a source and destination folder by yourself.

          For example, wherever your file is located, together with that is a source and destination folder.

          And that way, all you have to do is

          FileCopy App.path & "\<source folder>\Support .xls", App.path & "\<destinat ion folder>\Support 1.xls"
          Sorry, I am obviously missing your interpretation! The source folder is still "My documents" Destination folder is fine and the script will read that. Are you saying my script should read ??

          FileCopy App.Path & "\c:\my documents\Suppo rt.xls",....... .......... or
          FileCopy App.Path & "\my documents\suppo rt.xls",....... ..........

          I am a little lost?

          Thanks again

          Comment

          • Wernerh
            New Member
            • Jul 2007
            • 104

            #6
            Originally posted by Wernerh
            Sorry, I am obviously missing your interpretation! The source folder is still "My documents" Destination folder is fine and the script will read that. Are you saying my script should read ??

            FileCopy App.Path & "\c:\my documents\Suppo rt.xls",....... .......... or
            FileCopy App.Path & "\my documents\suppo rt.xls",....... ..........

            I am a little lost?

            Thanks again
            Please could you help me with defining the source folder. Sorry am a newbie and not sure how it would read.

            Dim sourcefolder as ............... . I would presume?

            Comment

            • Killer42
              Recognized Expert Expert
              • Oct 2006
              • 8429

              #7
              To find the actual path to things like My Documents, add this code in a new code module, then you can call the public function to retrieve them.

              [CODE=vb]Option Explicit
              DefLng A-Z

              Public Enum Special_Folder_ ID
              Desktop = &H0
              Internet = &H1
              Programs = &H2
              Controls = &H3
              Printers = &H4
              Personal = &H5
              Favourites = &H6
              Startup = &H7
              Recent = &H8
              SentTo = &H9
              StartMenu = &HB
              MyDocuments = &HC
              Fonts = &H14
              Windows = &H24
              System = &H25
              ProgramFiles = &H26
              MyPictures = &H27
              End Enum


              Private Declare Function SHGetFolderPath Lib "SHFOLDER.D LL" Alias "SHGetFolderPat hA" _
              (ByVal lOwner As Long, ByVal lFolder As Long, _
              ByVal lToken As Long, ByVal lReserved As Long, _
              ByVal strPath As String) As Long

              Public Function GetPathOf(Form_ Hwnd As Long, ByVal What As Special_Folder_ ID) As String
              Dim Buffer As String
              Buffer = Space$(260)
              If SHGetFolderPath (Form_Hwnd, What, -1&, &H0&, Buffer) = 0 Then
              GetPathOf = Left$(Buffer, InStr(Buffer, Chr$(0)) - 1)
              End If
              End Function[/CODE]

              Comment

              • fplesco
                New Member
                • Jul 2007
                • 82

                #8
                Originally posted by Killer42
                To find the actual path to things like My Documents, add this code in a new code module, then you can call the public function to retrieve them...
                Thanks Killer. This info seems to be very useful, even for me.

                Good day!

                Hey Werner -

                I hope this will solve your problem.
                Last edited by Killer42; Aug 17 '07, 10:08 AM. Reason: Shortened quote block

                Comment

                • Killer42
                  Recognized Expert Expert
                  • Oct 2006
                  • 8429

                  #9
                  Originally posted by fplesco
                  Thanks Killer. This info seems to be very useful, even for me.
                  Thanks. It's a modified version of some code I found through Google. I mainly simplified it a bit.

                  Comment

                  Working...