UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Renaming A File On Anyone's Desktop    
 
   
pablotx
post Jun 26 2018, 10:04 AM
Post#1



Posts: 18
Joined: 10-October 03



Have a problem. A lot of my users have different paths to their desktop. I am trying to rename an old file when a new file is available. I am trying to do this in vbscript as I can't do it in VBA as I am trying to rename the database the person is currently using... long story. So, I am thinking that I will set a procedure to start a vbscript that will pause while the database closes then renames the file. Problem is my code for renaming the file, doesn't find it. Any help would be greatly appreciated. Thanks in advance.

Dim locDesktop
Dim oSShell
Dim objFso

Set objFso = CreateObject("Scripting.FileSystemObject")

Set oSShell = CreateObject("WScript.Shell")

locDesktop = oSShell.SpecialFolders("Desktop")
objFso.MoveFile locDesktop & "NewCastle.accdb", locDesktop & "Newcastle2.accdb"
Go to the top of the page
 
theDBguy
post Jun 26 2018, 10:10 AM
Post#2


Access Wiki and Forums Moderator
Posts: 72,725
Joined: 19-June 07
From: SunnySandyEggo


Hi,

Can't check it right now but maybe the SpecialFolders method does not end in a backslash. If so, try adding it to your code. For example:

objFso.MoveFile locDesktop & "\NewCastle.accdb", locDesktop & "\Newcastle2.accdb"

Hope it helps...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
cheekybuddha
post Jun 26 2018, 10:13 AM
Post#3


UtterAccess VIP
Posts: 10,140
Joined: 6-December 03
From: Telegraph Hill


Running your code seems to prove DBguy's suspicions correct.

--------------------


Regards,

David Marten
Go to the top of the page
 
pablotx
post Jun 26 2018, 03:12 PM
Post#4



Posts: 18
Joined: 10-October 03



Thanks for the help. Got the script to work. Now, trying to call it in an event procedure. Having trouble with it.

Shell "wscript \\serverA\TopFolder\NextFolder\RenameFile.vbs", vbNormalFocus

I get an error of (Not enough storage is available to complete this operation.)

When I change the wscript to cscript, nothing happens...

Any ideas how to better call the external script? Thanks.

Go to the top of the page
 
theDBguy
post Jun 26 2018, 04:25 PM
Post#5


Access Wiki and Forums Moderator
Posts: 72,725
Joined: 19-June 07
From: SunnySandyEggo


The code looks correct. Have you manually tested the script to make sure you can call it from a network location?

Just curious...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    17th July 2018 - 07:41 PM