Anthony Padgett Posted September 24, 2015 Share Posted September 24, 2015 Hello Experts,I am trying to create a script that will go onto my network and copy a word document to a local folder then open it. When I hard code the FileCopy, it works perfectly, but when I use variables for file path and file name, only the local folder I need gets created. I cannot seem to get the file to open even when using the hard coded path in function FileOpen code. Here is my code with comments on what is happening.#include <FileConstants.au3>#include <MsgBoxConstants.au3>#include <WinAPIFiles.au3>$ProductName = "Microsoft Word 2013"$AbvLanguage = "ENG"$Network = "mynetwork"$Folder = "shared"$SampleDocs = "Sample Documents"$DocumentName = "Holiday Schedule.docx";Or$FileLocation = "mynetwork\shared\Sample Documents" SampleDocument ()Func SampleDocument();This commented out hard coded line of code below works and does the copy, create local folder, and paste;FileCopy ("\\mynetwork\shared\Sample Documents\Microsoft Word 2013\ENG\Holiday Schedule.docx","c:\Sample Documents\",8);The opening of FileOpen line of code below has not worked yet, even when the file copy worksFileOpen ("C:\Sample Documents\Holiday Schedule.docx") ;Here are the 2 versions of FileCopy code(I only need one, one that works) and 1 version of FileOpen code I want to use with variables that has not work, ever;FileCopy ("\\$Network\$Folder\$SampleDocs\$ProductName\$AbvLanguage\$DocumentName","c:\Sample Documents\",8);FileCopy ("\\$FileLocation\$ProductName\$AbvLanguage\$DocumentName","c:\Sample Documents\",8);FileOpen ("c:\$SampleDocs\$DocumentName")EndFuncWhat am I missing here? Is this as simple as you cannot use variables to create file paths in the FileCopy function? Link to comment Share on other sites More sharing options...
jguinch Posted September 24, 2015 Share Posted September 24, 2015 You must concatenate strings and variables, like this :FileCopy ("\\" & $Network & "\" & $Folder & "\" & $SampleDocs & "\" & $ProductName & "\" & $AbvLanguage & "\" & $DocumentName,"c:\Sample Documents\",8) Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Anthony Padgett Posted September 25, 2015 Author Share Posted September 25, 2015 (edited) I followed your suggestion but it is telling me its an Unterminated String. I feel like there should be a quote mark after DocumentName but that doesnt fix it either. When I run the following;FileCopy ("\\" & $Network & "\" & $Folder & "\" & $SampleDocs & "\" & $ProductName & "\" & $AbvLanguage & "\" $DocumentName,"c:\Sample Documents",8)I get the Error: Badly Formated Variable Or MacroI did use the code where network path was a variable and that worked. Dont know what the difference was but it worked.FileCopy ("\\" & $FileLocation & "\" & $ProductName & "\" & $AbvLanguage & "\" & $DocumentName,"c:\Sample Documents\",8) Maybe there is a limit to the amount of variables allowed in a string, though I doubt that. Edited September 25, 2015 by Anthony Padgett Link to comment Share on other sites More sharing options...
jguinch Posted September 25, 2015 Share Posted September 25, 2015 Because a & is missing before $DocumentNameCompare my code and yours. Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Anthony Padgett Posted September 25, 2015 Author Share Posted September 25, 2015 (edited) I was able to get both of them to work actually. I just retyped the code. Must be a space or something I cant see in there. Thank you! Now how do I get this file to open in its associated program like a double click... Edited September 25, 2015 by Anthony Padgett Link to comment Share on other sites More sharing options...
jguinch Posted September 25, 2015 Share Posted September 25, 2015 It seems you have to read the help file, at least. You will learn more thing by yourself than asking us each time here.What you're looking for is ShellExecute. Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now