Paul Sansom
Board Regular
- Joined
- Jan 28, 2013
- Messages
- 178
- Office Version
- 2021
- 2016
- Platform
- Windows
Help........
I wrote this sub to copy a file from my local drive to networked SharePoint drive with a renamed file from within Excel using cmd.exe window.
If i use the text code in the code lines shown in Red directly into the cmd window the file is copied.
When i run this code I get a message "The network name cannot be found"
What is the difference between running this from my code an directly in cmd window????
Any help or guidance most welcome
FYI The code runs without errors but the file is not copied
Of course the secondary question is....
Is there a better way to copy/paste a renamed file from a selectable folder into a specific SP folder. (I asked this already without replies so I'm guessing not)
Paul
I wrote this sub to copy a file from my local drive to networked SharePoint drive with a renamed file from within Excel using cmd.exe window.
If i use the text code in the code lines shown in Red directly into the cmd window the file is copied.
When i run this code I get a message "The network name cannot be found"
What is the difference between running this from my code an directly in cmd window????
Any help or guidance most welcome
FYI The code runs without errors but the file is not copied
Of course the secondary question is....
Is there a better way to copy/paste a renamed file from a selectable folder into a specific SP folder. (I asked this already without replies so I'm guessing not)
Paul
Code:
Sub Test3()
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 5
newSecond2 = Second(Now()) + 60
waitTime = TimeSerial(newHour, newMinute, newSecond)
waitTime2 = TimeSerial(newHour, newMinute, newSecond2)
Dim retVal As String
retVal = Shell("cmd.exe", vbNormalFocus)
Application.Wait waitTime
SendKeys "cd\", True ' back to root of drive
SendKeys "~", True
[COLOR=#FF0000] Application.SendKeys ("copy /y")
Application.SendKeys (" C:\Users\Paul\Pictures\Captures\original.PNG")
Application.SendKeys (" [/COLOR][URL="file://\\network.name.com\sites\test\SupplimentaryDocuments\filenewname.PNG"][COLOR=#FF0000]\\network.name.com\sites\test\SupplimentaryDocuments\filenewname.PNG[/COLOR][/URL][COLOR=#FF0000]")
Application.SendKeys ("~")[/COLOR]
Application.Wait waitTime2
SendKeys "exit", True
SendKeys "~", True
End Sub