Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace old path C:\Path\filename.pdf to new path K:\Path\filename.pdf

Status
Not open for further replies.

BubbaJean

IS-IT--Management
Jun 5, 2002
111
0
0
US
The code below moves the drawing from Drive C:\ to Drive K:how do I get the path to recongize the new path e.g.
K:\ inplace of C:I'm going crazy, hope someone can help.


Private Sub cmdMoveFiles_Click()
On Error GoTo ErrorX
Dim x As SHFILEOPSTRUCT
Dim StrFile As String
StrFile = Me.DS_X1.Value
'Copies the file in textbox DS_X1
'String function to get rid of the "#" from the hyperlink.
x.pFrom = Mid(StrFile, 2, Len(StrFile) - 2)
'Pastes the file to stated location.
x.pTo = "K:\"
x.fFlags = FOF_NOCONFIRMATION
x.wFunc = FO_COPY
SHFileOperation x
strSourcePath = "C:\Me.DS_X1.Value"
strDestinationPath = "K:\Me.DS_X1.Value"
'Set FS = CreatObject("scripting.FileSystemObject")
fs.CopyFile strSourcePath, strDestinationPath

MsgBox "Copy Complete.", vbOKOnly
Exit Sub
ErrorX:
MsgBox "Error #:" & Err.Number & " " & Err.Description & vbCrLf _
& "Copy Failed."
End Sub
 
Hmmmmmmmmmmmmm, I place in the your code and ran it now I get the following error message
"Error#:424 Object Required, Copy Failed"
below is the revised code

Private Sub cmdMoveFiles_Click()
On Error GoTo ErrorX
Dim x As SHFILEOPSTRUCT
Dim StrFile As String
StrFile = Me.DS_X1.Value
'Copies the file in textbox DS_X1
'String function to get rid of the "#" from the hyperlink.
x.pFrom = Mid(StrFile, 2, Len(StrFile) - 2)
'Pastes the file to stated location.
x.pTo = "K:\"
x.fFlags = FOF_NOCONFIRMATION
x.wFunc = FO_COPY
SHFileOperation x
fs.CopyFile strSourcePath, strDestinationPath
strSourcePath = "C:\" & Me.DS_X1.Value
strDestinationPath = "K:\" & Me.DS_X1.Value
Set fs = CreateObject("scripting.FileSystemObject", True)

MsgBox "Copy Complete.", vbOKOnly
Exit Sub
ErrorX:
MsgBox "Error #:" & Err.Number & " " & Err.Description & vbCrLf _
& "Copy Failed."
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top