team2005
asked on
What is wrong with this vb-script
Hi!
Have this vb-script
Gives me this error message ?
VBScript compilation error: Name redifined
What is wrong ?
Have this vb-script
Gives me this error message ?
VBScript compilation error: Name redifined
' VBSCRIPT
' Created by : Tor Erik Berg - Zoftzircus
' Date : 06 Aug 2012
' Versjon 1.0
'
' Script have this actions:
'
' 1. Emty directory \Nyimport
' 2. Locate csv-file file in \Vectura
' 3. Rename csv-file VBxxxxx.csv to artikkler_ddmmyy -> dd = day mm=month yy=year
' 4. Copy the artikkler_ddmmyy.csv file to Archive
' 5. Rename artikkler_ddmmyy.csv to artikkler.csv
' 2. Locate csv-file file in \Vectura
' 3. Rename csv-file VSxxxxx.csv to fakturalinjer_ddmmyy -> dd = day mm=month yy=year
' 4. Copy the fakturalinjer_ddmmyy.csv file to Archive
' 5. Rename fakturalinjer_ddmmyy.csv to fakturalinjer.csv
'
' Define folders involved, and file base name to process
'
Dim strBaseDir
Dim strDestDir1
Dim strDestDir2
Dim strArchive
Dim strMatchstat1
Dim strMatchstat2
strBaseDir = "I:\DataExchange\NO\Vectura\"
strDestDir1 = "I:\DataExchange\NO\Vectura\varebok\"
strDestDir2 = "I:\DataExchange\NO\Vectura\varesalg\"
strArchive = "I:\DataExchange\NO\Vectura\Archive\"
strMatchstat1 = "VB"
strMatchstat2 = "VS"
Dim filenobj1
' create objects varebok
Set filenobj1 = CreateObject("Scripting.FileSystemObject")
' Locate new varebok file
Dim varebokFile
varebokFile = ""
For Each objFile In filenobj1.GetFolder(strDestDir1).Files
If UCase(Left(objFile.Name, Len(strMatchstat1))) = UCase(strMatchstat1) Then
varebokFile = objFile.Path
End If
Next
' Rename varebok
Dim objartikkler
Set objartikkler = CreateObject("Scripting.FileSystemObject")
objartikkler.MoveFile varebokFile, strDestDir1 & "artikkler_" & Date & ".csv"
varebokFile = strDestDir1 & "artikkler_" & Date & ".csv"
' Copy file to Archive/varebok
Dim filenobj2
Set filenobj2 = CreateObject("Scripting.FileSystemObject")
filenobj2.CopyFile varebokFile, strArchive
' Rename varebok
Dim objartikkler2
Set objartikkler2 = CreateObject("Scripting.FileSystemObject")
objartikkler2.MoveFile varebokFile, strDestDir1 & "artikkler.csv"
varebokFile = strDestDir1 & "artikkler.csv"
' create objects fakturalinjer
Dim filenobj2
Set filenobj2 = CreateObject("Scripting.FileSystemObject")
' Locate new fakturalinjer file
fakturaFile = ""
For Each objFile In filenobj2.GetFolder(strDestDir2).Files
If UCase(Left(objFile.Name, Len(strMatchstat2))) = UCase(strMatchstat2) Then
fakturaFile = objFile.Path
End If
Next
' Rename fakturalinjer
Set objartikkler = CreateObject("Scripting.FileSystemObject")
objartikkler.MoveFile fakturaFile, strDestDir2 & "fakturalinjer_" & Date & ".csv"
fakturaFile = strDestDir2 & "fakturalinjer_" & Date & ".csv"
' Copy file to Archive/fakturalinjer
Dim filenobj1
Set filenobj1 = CreateObject("Scripting.FileSystemObject")
filenobj1.CopyFile fakturaFile, strArchive
' Rename fakturalinjer
Set objartikkler = CreateObject("Scripting.FileSystemObject")
objartikkler.MoveFile fakturaFile, strDestDir2 & "fakturalinjer.csv"
fakturaFile = strDestDir2 & "artikkler.csv"
What is wrong ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
ASKER
Aha, thanks