Technical support and scripting issues
Moderators: JRL, Dorian (MJT support)
-
PepsiHog
- Automation Wizard
- Posts: 517
- Joined: Wed Apr 08, 2009 4:19 pm
- Location: Florida
Post
by PepsiHog » Fri Jun 21, 2019 10:12 pm
Hello Everyone,
Does anyone know why I am getting "Path not found" with this vbs?
Code: Select all
VBStart
Option Explicit
Sub MoveFolder(Source,Dest)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.MoveFolder "%Source%","%Dest%"
End Sub
VBEND
//C:\Users\Felix The Cat\Desktop\Move this folder
//C:\Users\Felix The Cat\Desktop\Move here
let>Source=%Desktop_Dir%\Move this Folder
let>Dest=%Desktop_Dir%\Move here\
VBRun>MoveFolder,%Source%,%Dest%
Thanks,
PepsiHog
Windows 7
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!
-
Grovkillen
- Automation Wizard
- Posts: 1132
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
-
Contact:
Post
by Grovkillen » Sat Jun 22, 2019 6:14 am
Tried to quote the input variables?
Code: Select all
VBRun>MoveFolder,"%Source%","%Dest%"
-
PepsiHog
- Automation Wizard
- Posts: 517
- Joined: Wed Apr 08, 2009 4:19 pm
- Location: Florida
Post
by PepsiHog » Sat Jun 22, 2019 3:37 pm
Not sure what you mean. Did you scroll the window and I did thus suggesting that's wrong, or you didn't scroll and suggesting that is what it needs?
Thanks for helping,
Pepsihog
Windows 7
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!
-
Grovkillen
- Automation Wizard
- Posts: 1132
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
-
Contact:
Post
by Grovkillen » Sat Jun 22, 2019 6:14 pm
I'm nowhere near a computer (reading on a phone) and thought you could test to add quotes around the input to the VBA (the VBRun command).
-
PepsiHog
- Automation Wizard
- Posts: 517
- Joined: Wed Apr 08, 2009 4:19 pm
- Location: Florida
Post
by PepsiHog » Sat Jun 22, 2019 7:05 pm
I tried that and even removing them from the fso.movefolder line. Adding to vbrun made no difference. It still reports invalid path. The fso thing causes another error. I changed to %Desktop_Dir% to ensure the path was correct. I added \ to the end of each, together and one by one.
The answer is likely so dumb-foundingly stupid(easy) that it's gonna cause my head to spin in both directions and explode. And not in the good way, either.
I have no clue,
PepsiHog
Windows 7
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!
-
PepsiHog
- Automation Wizard
- Posts: 517
- Joined: Wed Apr 08, 2009 4:19 pm
- Location: Florida
Post
by PepsiHog » Sat Jun 22, 2019 7:08 pm
When writing a macro, do you ever feel like everything in the universe is simultaneously working against you?
PepsiHog
Windows 7
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!
-
Grovkillen
- Automation Wizard
- Posts: 1132
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
-
Contact:
Post
by Grovkillen » Sat Jun 22, 2019 8:26 pm
Try a message in the VBA code, containing the path variable to see how it looks.
-
PepsiHog
- Automation Wizard
- Posts: 517
- Joined: Wed Apr 08, 2009 4:19 pm
- Location: Florida
Post
by PepsiHog » Sat Jun 22, 2019 9:01 pm
I have tried every permutation I can think of. I even installed v12. If you insert the path directly into the vbscript it works. I went online and found another vbscript and it also works if the paths are directly inserted into the vbs. Using strings causes an error, "path not found".
To me, there is only one conclusion.
Thanks for helping,
PepsiHog
Windows 7
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!
-
Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
-
Contact:
Post
by Marcus Tettmar » Mon Jun 24, 2019 11:44 am
Your code should be:
Code: Select all
VBStart
Option Explicit
Sub MoveFolder(Source,Dest)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.MoveFolder Source, Dest
End Sub
VBEND
//C:\Users\Felix The Cat\Desktop\Move this folder
//C:\Users\Felix The Cat\Desktop\Move here
let>Source=%Desktop_Dir%\Move this Folder
let>Dest=%Desktop_Dir%\Move here\
VBRun>MoveFolder,%Source%,%Dest%
-
PepsiHog
- Automation Wizard
- Posts: 517
- Joined: Wed Apr 08, 2009 4:19 pm
- Location: Florida
Post
by PepsiHog » Mon Jun 24, 2019 2:38 pm
@Marcus,
Thanks. It worked. I swear I tried that previously.
PepsiHog
[edit] - Ok. I know. I did not try removing the parentheses. I tried removing the percent signs. Well doesn't this fit with exactly what I was saying. Something so simple. Dang! Isn't that a kick in the head!
Windows 7
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!
-
PepsiHog
- Automation Wizard
- Posts: 517
- Joined: Wed Apr 08, 2009 4:19 pm
- Location: Florida
Post
by PepsiHog » Mon Jun 24, 2019 10:09 pm
Hello Everyone,
Thanks goes out to Grovkillen and Marcus for the help with getting this VBScript working.
While I was trying to get the VBScript to work, I grabbed this script from the internet to see if it would work. I like this one because it has an 'IF' statement to be sure no error occurs.
Thanks to the help I received, I was able to also make the following VBScript work.
I thought I would share it. It may help others looking to move a folder within a MS script.
Code: Select all
let>Source=%Desktop_Dir%\Move This Folder
let>Dest=%Desktop_Dir%\Move Here\
VBStart
Sub MoveFolder (Source,Dest)
dim filesys
set filesys=CreateObject("Scripting.FileSystemObject")
If filesys.FolderExists(Source) And filesys.FolderExists(Dest) Then
filesys.MoveFolder Source,Dest
End If
End Sub
VBEND
VBRun>MoveFolder,%Source%,%Dest%
PepsiHog
Windows 7
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!