-
Apr 23rd, 2018, 04:27 AM
#1
Thread Starter
New Member
FileSystem.CopyFile not working on Shared Drive
Hello,
I am populating a spread sheet, via VS2010, which is stored on a shared drive.
Then it automatically create a separate folder with the name of that file, e.g. file "A.23.04.2018"
The problem comes when I try to copy the workbook from the shared drive onto its dedicated folder.
It doesn't even throw an error, just creates the folder which is always empty.
Code:
Private Sub CreateFolder()
Dim xlSheet As Object = CType(xlApp.Worksheets("Form"), Excel.Worksheet)
Dim YourPath As String = IO.Path.Combine("\\frtstpr-dna203a\tou5\Example_Design\11_SSBD\01_SSBD_Lcl_ad_open\Improvements\" + xlSheet.cells(6, 2).value.ToString + xlSheet.cells(6, 3).value.ToString + xlSheet.cells(6, 4).value.ToString)
Try
If (Not System.IO.Directory.Exists(YourPath)) Then
System.IO.Directory.CreateDirectory(YourPath)
End If
My.Computer.FileSystem.CopyFile( _
"\\frtstpr-dna203a\tou5\Example_Design\01_SSBD\01_SSBD_Lcl_ad_open\Improvements\TR tracker\TR_Template_Draft_01.xlsm", _
YourPath & ".xlsm", overwrite:=False)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Any help would be appreciated.
-
Apr 23rd, 2018, 04:46 AM
#2
Re: FileSystem.CopyFile not working on Shared Drive
Code:
Private Sub CreateFolder()
Dim xlSheet As Object = CType(xlApp.Worksheets("Form"), Excel.Worksheet)
Dim YourPath As String = IO.Path.Combine("\\frtstpr-dna203a\tou5\Example_Design\11_SSBD\01_SSBD_Lcl_ad_open\Improvements\" + xlSheet.cells(6, 2).value.ToString + xlSheet.cells(6, 3).value.ToString + xlSheet.cells(6, 4).value.ToString)
Try
If (Not System.IO.Directory.Exists(YourPath)) Then
System.IO.Directory.CreateDirectory(YourPath)
End If
messagebox.show(YourPath & ".xlsm") '<--- new! what is the path that is shown? maybe not what you expect? post the result.
My.Computer.FileSystem.CopyFile( _
"\\frtstpr-dna203a\tou5\Example_Design\01_SSBD\01_SSBD_Lcl_ad_open\Improvements\TR tracker\TR_Template_Draft_01.xlsm", _
YourPath & ".xlsm", overwrite:=False)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
-
Apr 23rd, 2018, 05:22 AM
#3
Thread Starter
New Member
Re: FileSystem.CopyFile not working on Shared Drive
Originally Posted by digitalShaman
Code:
Private Sub CreateFolder()
Dim xlSheet As Object = CType(xlApp.Worksheets("Form"), Excel.Worksheet)
Dim YourPath As String = IO.Path.Combine("\\frtstpr-dna203a\tou5\Example_Design\11_SSBD\01_SSBD_Lcl_ad_open\Improvements\" + xlSheet.cells(6, 2).value.ToString + xlSheet.cells(6, 3).value.ToString + xlSheet.cells(6, 4).value.ToString)
Try
If (Not System.IO.Directory.Exists(YourPath)) Then
System.IO.Directory.CreateDirectory(YourPath)
End If
messagebox.show(YourPath & ".xlsm") '<--- new! what is the path that is shown? maybe not what you expect? post the result.
My.Computer.FileSystem.CopyFile( _
"\\frtstpr-dna203a\tou5\Example_Design\01_SSBD\01_SSBD_Lcl_ad_open\Improvements\TR tracker\TR_Template_Draft_01.xlsm", _
YourPath & ".xlsm", overwrite:=False)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
That msgox you suggested clarified things, I just had to edit my path.
Thanks DigitalShaman!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|