Discussion Locked

Visual Basic Script Addition

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
Is there a command I can use that will prevent being asked if I want to copy over the existing document? I have a database that writes over existing files with a more current version but it keeps asking on each file if I want to replace the exisiting file.

6 replies

by alterego2

Your question is a little vague but I hope this is of some help.
The vbscript below uses the file system object to create a new file and the TRUE property allows you to overwrite the file if it already exists.

<%
dim objFile, objFolder, objFile
Set objFile = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFile.GetFolder("c:\foldername\")
Set objFile = objFolder.CreateTextFile("textfile.txt", True)
objFile.WriteLine("text goes here.")
objFile.Close
%>

by seagull data services

Assuming you're operating in Access

docmd.setwarnings False 'turns off warning messages
docmd.setwarnings True 'turns them back on and should be included in any error handling code.
Hope this helps
John

by jgreer

This is the actual script that isn't working. It should be copying the contents of these directories from one main share to other shares at other sites.
Cls
REM Empty all Document Share Directories
del W:\Adm\*.* /Y X:\Adm\*.* /Y Y:\Adm\*.* /Y Z:\Adm\*.* /Y
del W:\Ehs\*.* /Y X:\Ehs\*.* /Y Y:\Ehs\*.* /Y Z:\Ehs\*.* /Y
del W:\Eng\*.* /Y X:\Eng\*.* /Y Y:\Eng\*.* /Y Z:\Eng\*.* /Y
del W:\Hr\*.* /Y X:\Hr\*.* /Y Y:\Hr\*.* /Y Z:\Hr\*.* /Y
Copy U:\Adm\*.* /Y W:\Adm\*.* /Y
Copy U:\Adm\*.* /Y Y:\Adm\*.* /Y
Copy U:\Ehs\*.* /Y W:\Ehs\*.* /Y
Copy U:\Ehs\*.* /Y Y:\Ehs\*.* /Y
Copy U:\Eng\*.* /Y W:\Eng\*.* /Y
Copy U:\Eng\*.* /Y Y:\Eng\*.* /Y
Copy U:\Hr\*.* /Y W:\Hr\*.* /Y
Copy U:\Hr\*.* /Y Y:\Hr\*.* /Y
Copy U:\It\*.* /Y W:\It\*.* /Y
Copy U:\It\*.* /Y Y:\It\*.* /Y
Copy U:\Maint\*.* /Y W:\Maint\*.* /Y
Copy U:\Maint\*.* /Y Y:\Maint\*.* /Y
Copy U:\Op\*.* /Y W:\Op\*.* /Y
Copy U:\Op\*.* /Y Y:\Op\*.* /Y
Copy U:\Policy\*.* /Y W:\Policy\*.* /Y
Copy U:\Policy\*.* /Y Y:\Policy\*.* /Y
Exit

This discussion is closed to new replies.