MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically.

Recommended Posts

In my own way i have made a small batch script that uses user input to make a directory and .doc filename with the name the user gave.

I have got a office.document that is copied over with the name the user gave in the folder the user specified. (this document is always the same is copied over with name user gave)

after creation the document is opened so the user can fill in the document.

After creation of the document offerte_example.doc i need the script to find the offerte_example.doc file (only .doc file in folder) take its name en copie to factuur_example.doc, (offerte_example.doc needs to stay!)

after that change some text to another part of text. (text is always the same only needs to be changed to different text)

Share this post

Link to post

Share on other sites

UserInput in the script is a varible that can be passed to other parts of the script.

Example

Dim UserInput GetUserInput()

Function GetUserInput() Do UserInput = InputBox(_ "Text With Details About User Input Required" & vbCrLf & vbCrLf &_ "To Close And Do Nothing, Type Exit Or Quit","","",6500,5500) If InStr(1,UserInput,"exit",1) And Len(UserInput) = 4 Or _ InStr(1,UserInput,"quit",1) And Len(UserInput) = 4 Then WScript.Quit End if If Not UserInput = "" And Len(UserInput) >= 0 Then'-> User Input Passed To The Function WordDocument WordDocument(UserInput) Exit Do End if Loop Until Len(Input) = 1000 End Function

Share this post

Link to post

Share on other sites

1:\ Please note I do not have any experience at Networks, I only have one computer

2:\ This script is to replace choice /C:abcdefghijklmnopqrstuvwxyz /N >NUL

3:\ Tested this on my local drives and it copies the 2 files

In regards to Number 1 you will have read up on how to use VBS to connect to

another computer.

'-> This code is property of Gunsmokingman and Or Jake1Eye and you must have his permission to use.'-> This is only posted as example code and meant only to used as such.'-> Run Time ObjectsDim Act :Set Act = CreateObject("Wscript.Shell")Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")'-> Runtime VariblesDim Drv'-> Check To Make Both Files ExistsIf Fso.FileExists("offerte.doc") And Fso.FileExists("factuur.vbs") ThenGetDrvLtr()ElseMsgBox "Error Missing the offerte.doc or factuur.vbs."WScript.Quit()End IfFunction GetDrvLtr()'-> Loop To Keep Inputbox ActiveDo'-> Get Drive LetterDrv = InputBox(_"Type In The Drive Letter You Want To Use" & vbCrLf & vbCrLf &_"To Close And Do Nothing, Type Exit Or Quit","","",6500,5500)'-> Quit Or Exit ScriptIf InStr(1,Drv,"exit",1) And Len(Drv) = 4 Or _InStr(1,Drv,"quit",1) And Len(Drv) = 4 ThenWScript.QuitEnd ifIf Not IsNumeric(Drv) And Len(Drv) = 1 ThenIf Fso.DriveExists(Drv) ThenFso.CopyFile "offerte.doc", Drv & ":\"Fso.CopyFile "factuur.vbs", Drv & ":\"ElseMsgBox Drv & ":\ is missing. Type in another drive letter"GetDrvLtr()End IfExit DoEnd IfLoop Until Len(Drv) = 1000End Function