Question : Dynamic path for FileCopy function in VBA

I have a path in Excel VBA as below:
 FileCopy "D:\Always change Folder\Weight\Weight\MSADODC.OCX", "C:\WINDOWS\SYSTEM32\MSADODC.OCX"

Now, I wish to change the path "D:\Always change Folder\Weight" into a dynamic path. What is the code for this VBA Excel?

Answer : Dynamic path for FileCopy function in VBA

Hi poaysee,

How will the path be determined at run-time?  You could do:

    FileCopy ThisWorkbook.Path & "\Weight\MSADODC.OCX", "C:\WINDOWS\SYSTEM32\MSADODC.OCX" 'uses a property

or:

    FileCopy PathVariable & "\Weight\MSADODC.OCX", "C:\WINDOWS\SYSTEM32\MSADODC.OCX" 'uses a variable

or something else.  Please let us know how to resolve the path to be used, and then it is probably a simple matter to
write the statement.

Regards,

Patrick
Random Solutions  
 
programming4us programming4us