Generate barcode EAN13 in crystal report - crystal-reports

I would like to generate barcode EAN13 from a string(For example: 1234567890123) or where can I free download for EAN13.ttf?

This example worked for me:
http://www.aliquo.software/howto-generar-ean13-crystal-report/
To Print EAN13 with CrystalReport create a formula (sintaxis Basic):
With this code:
Function Generar_EAN13(Codigo As String) As String
' Esta función permite generar el código de barras para mostrarlo con la fuente EAN13.TTF
' - Parametros : código de 12 o 13 dígitos
' - Retorno: retorna una cadena que permite representar generar el código de barras con la fuente EAN13.TTF
' retorna una cadena vacía si no se puede representar el código de barras
dim i, first, checksum as number
dim code, code13 as string
dim tableA as boolean
' Evaluar los dígitos del código
If Len(Codigo) = 12 then
code = Codigo
ElseIf Len(Codigo) = 13 then
code = Left(Codigo,12)
Else
code = ""
end If
' VerIficar los dígitos del código
For i = 1 To LEN(code)
If Asc(Mid(code, i, 1)) < 48 Or Asc(Mid(code, i, 1)) > 57 Then
code = ""
Exit For
End If
Next
' Chequea los 12 dígitos y cálcula el digito de control
If Len(code) = 12 Then
For i = 12 To 1 Step -2
checksum = checksum + Val(Mid(code, i, 1))
Next
checksum = checksum * 3
For i = 11 To 1 Step -2
checksum = checksum + Val(Mid(code, i, 1))
Next
code = code & ToText((10 - checksum Mod 10) Mod 10,0)
' Si el código inicial tenía 13 dígitos comprueba si el nuevo código generado
' es igual y en caso contrario no se generar ningún código
If Len(Codigo)=13 and Codigo<>code then
code = ""
end If
End If
' Chequea los 13 dígitos
If Len(code) = 13 Then
' Los primeros 2 dígitos que suelen corresponder al código del país
code13 = Left(code, 1) & Chr(65 + Val(Mid(code, 2, 1)))
first = Val(Left(code, 1))
' Generar los códigos del primer bloque de dígitos
For i = 3 To 7
tableA = False
Select Case i
Case 3
Select Case first
Case 0 To 3
tableA = True
End Select
Case 4
Select Case first
Case 0, 4, 7, 8
tableA = True
End Select
Case 5
Select Case first
Case 0, 1, 4, 5, 9
tableA = True
End Select
Case 6
Select Case first
Case 0, 2, 5, 6, 7
tableA = True
End Select
Case 7
Select Case first
Case 0, 3, 6, 8, 9
tableA = True
End Select
End Select
If tableA Then
code13 = code13 & Chr(65 + Val(Mid(code, i, 1)))
Else
code13 = code13 & Chr(75 + Val(Mid(code, i, 1)))
End If
Next
' Añadir el separador de los bloques
code13 = code13 & "*"
' Generar los códigos del segundo bloque de dígitos
For i = 8 To 13
code13 = code13 & Chr(97 + Val(Mid(code, i, 1)))
Next
' Añadir la marca final
code13 = code13 & "+"
End If
Generar_EAN13=code13
End Function
Install this font (EAN13.ttf) in your PC:
http://download.aliquosoftware.net/documentation/ean13.ttf
Or alternative from here:
http://grandzebu.net/informatique/codbar/ean13.ttf
Add a text formula with the call. For example:
Configure it with the font installed:
Then, you will see the EAN 13 code:
For more information, you can see this web:
http://grandzebu.net/informatique/codbar-en/ean13.htm

Related

How to write alternative constraint with interval variable in or-tools?

How to write alternative constraint with interval variable in or-tools? I thought something like this would work but the method AddAlternative doesn´t exist. Another question is how to know if interval variable is active
from ortools.sat.python import cp_model
# Crear el modelo
model = cp_model.CpModel()
# Crear la variable de intervalo
interval = model.NewIntervalVar(start, end, duration, 'interval')
# Crear los intervalos alternativos
alt_interval1 = model.NewIntervalVar(start1, end1, duration1, 'alt_interval1')
alt_interval2 = model.NewIntervalVar(start2, end2, duration2, 'alt_interval2')
# Agregar los intervalos alternativos a la variable de intervalo
model.AddAlternative(interval, [alt_interval1, alt_interval2])
# Resolver el modelo
solver = cp_model.CpSolver()
status = solver.Solve(model)
My code is:
# VARIABLES#
x = [
model.NewIntervalVar(
start=model.NewIntVar(es, lf, f"start_{row.id_pozo}"),
size=model.NewIntVar(es, lf, f"size_{row.id_pozo}"),
end=model.NewIntVar(es, lf, f"end_{row.id_pozo}"),
name="pozo_intv_{}".format(row.id_pozo),
)
for row in pozos.itertuples()
]
y = [
model.NewOptionalIntervalVar(
start=model.NewIntVar(row.dia_inicio, row.dia_fin, f"start_{idx}"),
size=row.tiempo_total,
end=model.NewIntVar(row.dia_inicio, row.dia_fin, f"end_{idx}"),
is_present=True,
name="pte_intv_{}".format(idx),
)
for idx, row in pozo_time_equipment.iterrows()
]
This is a flexible job shop problem. In the OR tools source there is a working example. The basics are, firstly creating the main interval for each task:
# Create main interval for the task.
suffix_name = '_j%i_t%i' % (job_id, task_id)
start = model.NewIntVar(0, horizon, 'start' + suffix_name)
duration = model.NewIntVar(min_duration, max_duration,
'duration' + suffix_name)
end = model.NewIntVar(0, horizon, 'end' + suffix_name)
interval = model.NewIntervalVar(start, duration, end,
'interval' + suffix_name)
Then for each alternative, create an additional interval:
alt_suffix = '_j%i_t%i_a%i' % (job_id, task_id, alt_id)
l_presence = model.NewBoolVar('presence' + alt_suffix)
l_start = model.NewIntVar(0, horizon, 'start' + alt_suffix)
l_duration = task[alt_id][0]
l_end = model.NewIntVar(0, horizon, 'end' + alt_suffix)
l_interval = model.NewOptionalIntervalVar(
l_start, l_duration, l_end, l_presence,
'interval' + alt_suffix)
l_presences.append(l_presence)
The alternative is linked to the main interval, only if the alternative is selected:
# Link the primary/global variables with the local ones.
model.Add(start == l_start).OnlyEnforceIf(l_presence)
model.Add(duration == l_duration).OnlyEnforceIf(l_presence)
model.Add(end == l_end).OnlyEnforceIf(l_presence)
Then finally, add a constraint to ensure that only one of the alternatives is selected:
# Select exactly one presence variable.
model.AddExactlyOne(l_presences)

Data back NULL in OPC UA client with VB.net

im trying to connect to a S7 1500 PLC with an OPC UA client with the Visual Studio using VB.net.
The project need to be auto, so i have an Excel that have the names of the variables that i will read with the OPC connection.
The problem is that when i try to read a single node it works and give me back the value correctly, but when i tried to do it with an array to save the data (for later introduccing it in an SQL Server) i gave me back the value NULL, i have tried to convert using CType or other but it still fails.
here Is the code:
The variable Arr_Celdas contanins the names of the vars for the string. The var Rwcnt is a function that reads the number of rows in the Excel(number of variables). And the Var Filas is for the Fors
Dim Client_OPC As New OpcClient("opc.tcp://10.1.0.128:4840") 'Conexión
Dim Lectura_OPC(Fila) As String 'Array con los nombres de las variables para la lectura de valores OPC
Dim Valor_Nodo_OPC(Rwcnt) As OpcValue 'Variable con el valor del nodo OPC
Client_OPC.Connect() 'Conexión al servidor
If Err.Number = 0 Then 'Rutina de espera antes del siguiente paso y rutina de error
Console.WriteLine("Cliente OPC conectado")
System.Threading.Thread.Sleep(2000)
Else
Dim ErrorDesc As String = Err.Description & "(" & Err.Number & ")"
Console.WriteLine(ErrorDesc)
Client_OPC.Disconnect()
Exit Sub
End If
Dim Lectura_OPC_1 As String = """ns = 3;s=""Registros_procesados"".""Registros_ATV_Izda""."""
Dim Lectura_OPC_2(Fila) As String
For Fila = 1 To Rwcnt
Lectura_OPC_2(Fila) = Arr_Celdas(Fila) + """"
Lectura_OPC(Fila) = Lectura_OPC_1 + Lectura_OPC_2(Fila) + """"
Next
'Console.WriteLine(Lectura_OPC(11))
Do While (True) 'Bucle cada 100 ms
'Dim Prueba As OpcValue = Client_OPC.ReadNode("ns=3;s=""Registros_procesados"".""Registros_ATV_Izda"".""Encoder frequency""") 'Valor encoder y lectura del nodo correspondiente
For Fila = 1 To Rwcnt
Valor_Nodo_OPC(Fila) = CType(Client_OPC.ReadNode(Lectura_OPC(Fila)), OpcValue)
Next
If Err.Number = 0 Then 'Rutina de espera antes del siguiente paso y rutina de error
Console.WriteLine("Obteniendo valores")
'System.Threading.Thread.Sleep(2000)
Else
Dim ErrorDesc As String = Err.Description & "(" & Err.Number & ")"
Console.WriteLine(ErrorDesc)
Client_OPC.Disconnect()
Exit Sub
End If
Console.WriteLine(Valor_Nodo_OPC(11))
THANKS AND HOPE U CAN HELP ME :)

Ortools VRP error when trying to merge penalties and different start-end depots

I'm trying to solve a VRP problem allowing dropping nodes through penalties and multiple depots.
Code works fine with penalties and vehicles starting and ending at the same depots:
data['num_vehicles'] = 2
data['start'] = [0, 4]
data['end'] = [0, 4]
Code works fine with vehicles starting and ending at different depots, commenting the for loop to AddDisjunction for penalties (without allowing dropping nodes):
data['num_vehicles'] = 2
data['start'] = [0, 4]
data['end'] = [0, 9]
.........................
#for node in range(1, len(data['penalties'])):
# routing.AddDisjunction([manager.NodeToIndex(node)], data['penalties'][node])
But with vehicles starting and ending at different depots and trying to add penalties to allow dropping nodes, python crashes with the error (debugging I can see that fails at adding the penalty of the different end depot):
F00-1 -1:-1:-1.000244 24944 routing.cc:1622] Check failed: kUnassigned != indices[i] (-1 vs. -1)
I cannot find any reference about this error. I looked at routing.cc source code around line 1622, but I cannot see any relation with the error. I need help to fix the problem.
Here is the souce code:
from ortools.constraint_solver import routing_enums_pb2
from ortools.constraint_solver import pywrapcp
def create_data_model():
"""Stores the data for the problem."""
data = {}
data['distance_matrix'] = [
[0, 2253, 2479, 2792, 4707, 6128, 1567, 5643, 1234, 3345, 1827],
[1731, 0, 2193, 2507, 3624, 5040, 3467, 2921, 5791, 1546, 2345],
[1867, 2112, 0, 676, 4406, 5824, 988, 4567, 2134, 4453, 2123],
[2339, 2585, 893, 0, 4879, 6302, 1543, 1298, 6890, 1456, 5623],
[4464, 3766, 5935, 4957, 0, 1749, 987, 3212, 3451, 5212, 3321],
[6568, 5862, 8023, 7055, 2148, 0, 4567, 2124, 4321, 3212, 1234],
[731, 2193, 2507, 7624, 4040, 4467, 0, 2621, 3791, 1567, 1345],
[1731, 3193, 1507, 3624, 6040, 2467, 4921, 0, 5791, 6723, 1345],
[2731, 3193, 2507, 6204, 5040, 1467, 2210, 6791, 0, 2567, 6421],
[3345, 1543, 4421, 1531, 5213, 3215, 1512, 6213, 2431, 0, 5673],
[1832, 2421, 2144, 5232, 3214, 1234, 1432, 1231, 6321, 5461, 0],
]
data['node_time'] = [0, 7200, 3600, 5400, 0, 5400, 7200, 3600, 7200, 0, 300]
data['num_vehicles'] = 2
data['start'] = [0, 4]
data['end'] = [0, 9]
# Penalizaciones por no visitar nodos (drop nodes) en caso de que no tenga solución:
# MAXINT 0x7FFFFFFFFFFFFFF: Hace obligatoria la visita al nodo, no se puede eliminar de la solución
# 1000000: Se puede no visitar el nodo con penalización. La penalización debe ser grande, mayor que 10x veces el mayor tiempo de visita, para evitar que salga mas rentable dejar caer el nodo que pagar la penalización
# 0: En los nodos "depósito" de vehículos, no son visitas intermedias sino inicio y fin de la ruta.
data['penalties'] = [0, 1000000, 1000000, 1000000, 0, 0x7FFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFF, 1000000, 1000000, 0, 1000000]
return data
def print_solution(data, manager, routing, solution):
"""Prints solution on console."""
print(f'Objective: {solution.ObjectiveValue()}')
# Display dropped nodes.
dropped_nodes = 'Nodos sin visitar:'
for node in range(routing.Size()):
if routing.IsStart(node) or routing.IsEnd(node):
continue
if solution.Value(routing.NextVar(node)) == node:
dropped_nodes += ' {}'.format(manager.IndexToNode(node))
print(dropped_nodes + '\n')
max_route_distance = 0
for vehicle_id in range(data['num_vehicles']):
index = routing.Start(vehicle_id)
plan_output = 'Ruta para vehículo {}:\n'.format(vehicle_id)
route_distance = 0
while not routing.IsEnd(index):
plan_output += ' {} -> '.format(manager.IndexToNode(index))
previous_index = index
index = solution.Value(routing.NextVar(index))
route_distance += routing.GetArcCostForVehicle(
previous_index, index, vehicle_id)
plan_output += '{}\n'.format(manager.IndexToNode(index))
plan_output += 'Tiempo de la ruta: {}sg\n'.format(route_distance)
print(plan_output)
max_route_distance = max(route_distance, max_route_distance)
print('Maximo tiempo de las rutas: {}sg'.format(max_route_distance))
def main():
"""Entry point of the program."""
# Instantiate the data problem.
data = create_data_model()
# Create the routing index manager.
manager = pywrapcp.RoutingIndexManager(len(data['distance_matrix']),
data['num_vehicles'], data['start'], data['end'])
# Create Routing Model.
routing = pywrapcp.RoutingModel(manager)
# Create and register a transit callback.
def distance_callback(from_index, to_index):
"""Returns the distance between the two nodes."""
# Convert from routing variable Index to distance matrix NodeIndex.
from_node = manager.IndexToNode(from_index)
to_node = manager.IndexToNode(to_index)
tiempo_desplazamiento = data['distance_matrix'][from_node][to_node]
tiempo_ejecucion = data['node_time'][to_node]
return tiempo_desplazamiento + tiempo_ejecucion
transit_callback_index = routing.RegisterTransitCallback(distance_callback)
# Define cost of each arc.
routing.SetArcCostEvaluatorOfAllVehicles(transit_callback_index)
# Add Distance constraint.
routing.AddDimension(
transit_callback_index,
0, # no slack
27000, # vehicle maximum travel distance (7.5 hours, in seconds)
True, # start cumul to zero
'Time')
distance_dimension = routing.GetDimensionOrDie('Time')
distance_dimension.SetGlobalSpanCostCoefficient(100)
# Allow to drop nodes.
for node in range(1, len(data['penalties'])):
routing.AddDisjunction([manager.NodeToIndex(node)], data['penalties'][node])
# Setting first solution heuristic.
search_parameters = pywrapcp.DefaultRoutingSearchParameters()
search_parameters.first_solution_strategy = (routing_enums_pb2.FirstSolutionStrategy.PATH_CHEAPEST_ARC)
search_parameters.local_search_metaheuristic = (routing_enums_pb2.LocalSearchMetaheuristic.GUIDED_LOCAL_SEARCH)
search_parameters.time_limit.seconds = 30
# Solve the problem.
solution = routing.SolveWithParameters(search_parameters)
# Print solution on console.
if solution:
print_solution(data, manager, routing, solution)
else:
print('No solution found!')
if __name__ == '__main__':
main()
I've posted the question in Ortools Google Group, with additional research:
[https://groups.google.com/g/or-tools-discuss/c/s3PfgLVZpj0][1]
Code seems to be working excluding start and end nodes from the disjunction as explained on that post, but I asked for more info to understand how it works.
With custom start and ends, you should use Routing.Start(vehicle_index) and Routing.End(vehicle_index) to get the index of these nodes.
In routing.h there is a comment about AddDisjunction
/// Adds a disjunction constraint on the indices: exactly 'max_cardinality' of
/// the indices are active. Start and end indices of any vehicle cannot be
/// part of a disjunction.
In the for loop to add nodes to the disjunction, excluding start and end nodes seems to be working:
# Allow to drop nodes.
for node in range(0, len(data['distance_matrix'])):
if(node in data['start'] or node in data['end']):
continue
else:
routing.AddDisjunction([manager.NodeToIndex(node)], data['penalties'][node])

Folder Subdirectory "Table of contents" listing

I have zero scripting/coding experience.
My objective is this:
To create a script (VBS, Powershell, CMD.bat) that will dynamically create a table of contents of a Flash Drive.
This flash drive will be used in multiple machines, so the drive letter won't be static.
What I need is the dynamic table of contents (subfolders only) of a flash drive.
I've tried
dir /a:d /s /b | sort
which presented an output too large and cumbersome to read
I've attempted to create a recursive powershell script
Get-ChildItem -Recurse | ?{ $_.PSIsContainer }
It is much cleaner, but not any closer to what I'm needing.
I stubmled accross
Get-ChildItem | where {$_.PsIsContainer} | Select-Object Name |
Export-Csv onlyFiles.csv
Which is much closer to what I'm looking for, but for the life of me, I can't get it "recursive".
Is there a way to modify this code so 1) it's recursive and 2) it's subolders only.
To be honest, I'd be happy with the Get-ChildItem -Recurse | ?{ $_.PSIsContainer } command to be subfolder only.
Is what I want possible, or is my reach exceeding my grasp?
Thank you in advance for your efforts and information.
=============
The table of contents need to look like this:
Root:\
Root:\Dir_n1
Root:\Dir_n1\Dir_n2\
Root:\Dir_N1\Dir_n2\Dir_n3
Dir2Html.vbs generate a list of files and folders in HTML with tree :
Option Explicit
Dim oFilesys,oFiletxt,Path,Ws,SourceImgFolder,StartTime,MsgTitre,DurationTime,objFolder,CheminDossier,Dossier,Copyright
Dim SizeKo,SizeMo,SizeGo,objShell,size,Sig,OutFile,MsgAttente,oExec,Temp
Copyright = "© Hackoo © 2014"
Set ws = CreateObject("wscript.Shell")
Temp = ws.ExpandEnvironmentStrings("%Temp%")
MsgTitre = "Generer une arborescence d'un dossier en HTML "&Copyright&""
MsgAttente = "Veuillez patienter un peu la generation est en cours..."
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(0, "Veuillez choisir un dossier "&Copyright, 1, "c:\Programs")
If objFolder Is Nothing Then
WScript.Quit
End If
CheminDossier = objFolder.self.path
OutFile = objFolder.self.name &".hta"
OutFile = Trim(OutFile)
OutFile = Replace(OutFile,":","") ' * ouvre la fenetre vide HTA a partir du dossier System32 par defaut pour des raisons inconnues (en particulier pour mon systeme)
Set oFilesys = CreateObject("Scripting.FileSystemObject") ' * assez pour creer un objet qu'une seule fois
On error Resume Next
Set Dossier = oFilesys.GetFolder(CheminDossier)
If Err <> 0 Then
MsgBox Err.Number & VbCrLF & Err.Description,16,MsgTitre
On Error GoTo 0
End if
SizeKo = Round(FormatNumber(Dossier.Size)/(1024),2) & " Ko" 'Taille en Ko avec 2 chiffres apres la Virgule
SizeMo = Round(FormatNumber(Dossier.Size)/(1048576),2) & " Mo" 'Taille en Mo avec 2 chiffres apres la Virgule
SizeGo = Round(FormatNumber(Dossier.Size)/(1073741824),2) & " Go" 'Taille en Go avec 2 chiffres apres la Virgule
If Dossier.size < 1024 Then
Size = Dossier.size & " Octets"
elseif Dossier.size < 1048576 Then
Size = SizeKo
elseif Dossier.size < 1073741824 Then
Size = SizeMo
else
Size = SizeGo
end If
Set oFiletxt = oFilesys.CreateTextFile(OutFile,True,-1)
Set Ws = CreateObject("Wscript.Shell")
oFiletxt.WriteLine("<html><HTA:APPLICATION SCROLL=""yes"" WINDOWSTATE=""Maximize""icon=""verifier.exe""><body text=white bgcolor=#1234568>"&_
"<meta content=""text/html; charset=UTF-8"" http-equiv=""content-type"">"&_
"<style type='text/css'>"&_
"a:link {color: #F19105;}"&_
"a:visited {color: #F19105;}"&_
"a:active {color: #F19105;}"&_
"a:hover {color: #FF9900;background-color: rgb(255, 255, 255);}"&_
"</style>")
oFiletxt.writeline "<SCRIPT LANGUAGE=""VBScript"">"
oFiletxt.writeline "Function Explore(filename)"
oFiletxt.writeline "Set ws=CreateObject(""wscript.Shell"")"
oFiletxt.writeline "ws.run ""Explorer /n,/select,""&filename&"""""
oFiletxt.writeline "End Function"
oFiletxt.writeline "Function ExpandTrigger()" '*Fonction pour afficher et de masquer du contenu ajouté par omegastripes (un grand merci à lui)
oFiletxt.writeline " With Window.Event.SrcElement" 'http://www.visualbasicscript.com/fb.ashx?m=104343
oFiletxt.writeline " If .FirstChild.NodeValue = ""+"" Then"
oFiletxt.writeline " .FirstChild.NodeValue = ""–"""
oFiletxt.writeline " .NextSibling.NextSibling.NextSibling.Style.Display = ""inline"""
oFiletxt.writeline " Else"
oFiletxt.writeline " .FirstChild.NodeValue = ""+"""
oFiletxt.writeline " .NextSibling.NextSibling.NextSibling.Style.Display = ""none"""
oFiletxt.writeline " End If"
oFiletxt.writeline " End With"
oFiletxt.writeline "End Function"
oFiletxt.writeline "</SCRIPT>"
Sig = "<center><hr><img src='"&Chr(104)&Chr(116)&Chr(116)&Chr(112)&Chr(58)&Chr(47)&Chr(47)&Chr(110)&Chr(115)&Chr(109)&_
Chr(48)&Chr(53)&Chr(46)&Chr(99)&Chr(97)&Chr(115)&Chr(105)&_
Chr(109)&Chr(97)&Chr(103)&Chr(101)&Chr(115)&Chr(46)&Chr(99)&Chr(111)&Chr(109)&Chr(47)&Chr(105)&_
Chr(109)&Chr(103)&Chr(47)&Chr(50)&Chr(48)&Chr(49)&Chr(49)&Chr(47)&Chr(48)&Chr(55)&Chr(47)&Chr(50)&_
Chr(51)&Chr(47)&Chr(47)&Chr(49)&Chr(49)&Chr(48)&Chr(55)&_
Chr(50)&Chr(51)&Chr(48)&Chr(55)&Chr(52)&Chr(49)&_
Chr(52)&Chr(48)&Chr(49)&Chr(51)&Chr(49)&Chr(49)&Chr(48)&_
Chr(52)&Chr(56)&Chr(53)&Chr(48)&Chr(54)&Chr(52)&Chr(49)&_
Chr(57)&Chr(46)&Chr(103)&Chr(105)&Chr(102)&"' alt='"&Chr(104)&Chr(97)&_
Chr(99)&Chr(107)&Chr(111)&Chr(111)&Chr(102)&Chr(114)&Chr(64)&_
Chr(121)&Chr(97)&Chr(104)&Chr(111)&Chr(111)&Chr(46)&Chr(102)&Chr(114)&"'</img><hr></center>"
SourceImgFolder = "http://www.webmasters.by/images/articles/css-tree/folder-horizontal.png"
'"http://upload.wikimedia.org/wikipedia/commons/a/a4/Icons-mini-folder.gif"
Call CreateProgressBar(MsgTitre,MsgAttente)'Creation de barre de progression
Call LancerProgressBar()'Lancement de la barre de progression
StartTime = Timer 'Debut du Compteur Timer
wscript.sleep 5000
oFiletxt.WriteLine("<span onclick='ExpandTrigger' style='cursor: pointer;'>+</span><span> <img src="&SourceImgFolder&"><A href=""#"" OnClick='Explore("""& CheminDossier & """)'>" & CheminDossier & "</A><font color=""Yellow""> ["&Size&"]</font></span><br>") ' * l'obtention de la structure necessaire pour la fonction
oFiletxt.WriteLine("<div style='display: none;'>")
List(CheminDossier)
oFiletxt.WriteLine("</div>")
oFiletxt.WriteLine(Sig)
oFiletxt.WriteLine("</body></hmtl>")
oFiletxt.Close
Call FermerProgressBar()'Fermeture de barre de progression
DurationTime = FormatNumber(Timer - StartTime, 0) & " seconds." 'La duree de l'execution du script
Ws.Popup "La generation au format HTML est terminee en "& DurationTime & " !","2",MsgTitre,64
Ws.Run DblQuote(OutFile), 1, True ' * apres l'utilisation
'oFilesys.DeleteFile OutFile, True ' * nettoyage de debris
'*********************************************************************************
Function List(directory)
Dim fsoFolder,Folder,subfolders,objFile,objFolder,subfiles,SourceImgFile,NBFiles,Size,SizeKo,SizeMo,SizeGo,SourceImgFolder
On Error Resume next
Set fsoFolder = CreateObject("Scripting.FileSystemObject")
Set folder = fsoFolder.GetFolder(directory)
Set subfolders = folder.SubFolders
Set subfiles = folder.Files
SourceImgFolder = "http://www.webmasters.by/images/articles/css-tree/folder-horizontal.png"
'"http://upload.wikimedia.org/wikipedia/commons/a/a4/Icons-mini-folder.gif"
SourceImgFile = "http://upload.wikimedia.org/wikipedia/en/d/d8/VBSccript_file_format_icon.png"
NBFiles = 0
For each objFile in subfiles
NBFiles = NBFiles + 1
SizeKo = Round(FormatNumber(objFile.Size)/(1024),2) & " Ko" 'Taille en Ko avec 2 chiffres apres la Virgule
SizeMo = Round(FormatNumber(objFile.Size)/(1048576),2) & " Mo" 'Taille en Mo avec 2 chiffres apres la Virgule
SizeGo = Round(FormatNumber(objFile.Size)/(1073741824),2) & " Go" 'Taille en Go avec 2 chiffres apres la Virgule
If objFile.size < 1024 Then
Size = objFile.size & " Octets"
elseif objFile.size < 1048576 Then
Size = SizeKo
elseif objFile.size < 1073741824 Then
Size = SizeMo
else
Size = SizeGo
end If
oFiletxt.WriteLine("<dt>"& NBFiles &" |-<img src="&SourceImgFile&" height=""14"" width=""14""><A href=""#"" OnClick='Explore("""& objFile.Path & """)'>" & objFile.Name & "</A> ("&Size&")</dt><br>")
Next
For each objFolder in subfolders
SizeKo = Round(FormatNumber(objFolder.Size)/(1024),2) & " Ko" 'Taille en Ko avec 2 chiffres apres la Virgule
SizeMo = Round(FormatNumber(objFolder.Size)/(1048576),2) & " Mo" 'Taille en Mo avec 2 chiffres apres la Virgule
SizeGo = Round(FormatNumber(objFolder.Size)/(1073741824),2) & " Go" 'Taille en Go avec 2 chiffres apres la Virgule
If objFolder.size < 1024 Then
Size = objFolder.size & " Octets"
elseif objFolder.size < 1048576 Then
Size = SizeKo
elseif objFolder.size < 1073741824 Then
Size = SizeMo
else
Size = SizeGo
end If
oFiletxt.WriteLine("<DL><hr>")
oFiletxt.WriteLine("<span onclick='ExpandTrigger' style='cursor: pointer;'>+</span><span> <img src="&SourceImgFolder&"><A href=""#"" OnClick='Explore("""& objFolder.Path & """)'>" & objFolder.Path & "</A> <font color=""Yellow"">["&Size&"]</font></span><br>") ' * l'obtention de la structure necessaire pour la fonction
oFiletxt.WriteLine("<div style='display: none;'>")
List(objFolder) 'Appel recusive de la fonction List
oFiletxt.WriteLine("</div>")
oFiletxt.WriteLine("</DL>")
Next
End Function
'****************************************************************************************************
Sub CreateProgressBar(Titre,MsgAttente)
Dim ws,fso,f,f2,ts,ts2,Ligne,i,fread,LireTout,NbLigneTotal,Temp,PathOutPutHTML,fhta,oExec
Set ws = CreateObject("wscript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Temp = WS.ExpandEnvironmentStrings("%Temp%")
PathOutPutHTML = Temp & "\Barre.hta"
Set fhta = fso.OpenTextFile(PathOutPutHTML,2,True)
fhta.WriteLine "<HTML>"
fhta.WriteLine "<HEAD>"
fhta.WriteLine "<Title> " & Titre & "</Title>"
fhta.WriteLine "<HTA:APPLICATION"
fhta.WriteLine "ICON = ""magnify.exe"" "
fhta.WriteLine "BORDER=""THIN"" "
fhta.WriteLine "INNERBORDER=""NO"" "
fhta.WriteLine "MAXIMIZEBUTTON=""NO"" "
fhta.WriteLine "MINIMIZEBUTTON=""NO"" "
fhta.WriteLine "SCROLL=""NO"" "
fhta.WriteLine "SYSMENU=""NO"" "
fhta.WriteLine "SELECTION=""NO"" "
fhta.WriteLine "SINGLEINSTANCE=""YES"">"
fhta.WriteLine "</HEAD>"
fhta.WriteLine "<BODY text=""white""><CENTER><DIV><SPAN ID=""ProgressBar""></SPAN>"
fhta.WriteLine "<span><marquee DIRECTION=""LEFT"" SCROLLAMOUNT=""3"" BEHAVIOR=ALTERNATE><font face=""Comic sans MS"">" & MsgAttente &"</font></marquee></span></DIV></CENTER></BODY></HTML>"
fhta.WriteLine "<SCRIPT LANGUAGE=""VBScript""> "
fhta.WriteLine "Set ws = CreateObject(""wscript.Shell"")"
fhta.WriteLine "Temp = WS.ExpandEnvironmentStrings(""%Temp%"")"
fhta.WriteLine "Sub window_onload()"
fhta.WriteLine " CenterWindow 430,90"
fhta.WriteLine " Self.document.bgColor = ""Orange"" "
fhta.WriteLine " End Sub"
fhta.WriteLine " Sub CenterWindow(x,y)"
fhta.WriteLine " Dim iLeft,itop"
fhta.WriteLine " window.resizeTo x,y"
fhta.WriteLine " iLeft = window.screen.availWidth/2 - x/2"
fhta.WriteLine " itop = window.screen.availHeight/2 - y/2"
fhta.WriteLine " window.moveTo ileft,itop"
fhta.WriteLine "End Sub"
fhta.WriteLine "</script>"
fhta.close
End Sub
'**********************************************************************************************
Sub LancerProgressBar()
Set oExec = Ws.Exec("mshta.exe " & Temp & "\Barre.hta")
End Sub
'**********************************************************************************************
Sub FermerProgressBar()
oExec.Terminate
End Sub
'**********************************************************************************************
Function DblQuote(Str)
DblQuote = Chr(34) & Str & Chr(34)
End Function
'**********************************************************************************************
I have figured out the correct command, after bashing my head against the wall until the egg broke.
Get-ChildItem **** | ?{ $_.PSIsContainer } | select-object FullName | out-string -Width 255 > Table_of_Contents.txt
Thank you for your help and assistance.

Error in sending automatically emails using CDO

I've got an Excel Range including mailto email addresses for clients and a path to reach an invoice to enclosed in an email.
My code consists in sending an email (with an invoice) to each mailto address (from my gmail account).
Even if I don't include the attachment, I get an Automation error. Why?
Sub SendMail()
Dim oCdo As Object
Dim oConf As Object
Dim Flds As Object
Dim strHtml As String 'variable contenu du corps de message
Dim destinataire As String
Dim attachment As String
Dim DerLig
' Définit le contenu du message au format HTML
strHtml = "<HTML><HEAD><BODY>"
strHtml = strHtml & "<center><b> Ceci est un message de test au format <i><Font Color=#ff0000 > HTML. </Font></i></b></center>"
strHtml = strHtml & "</br>Veuillez prendre connaissance de la piece jointe."
strHtml = strHtml & "</BODY></HEAD></HTML>"
DerLig = Range("A" & Rows.Count).End(xlUp).Row
For n = 1 To DerLig
n = n + 1
destinataire = Cells(n, 3).Value
attachement = Cells(n, 8).Value
Set oCdo = CreateObject("cdo.Message")
'Set oConf = CreateObject("cdo.configuration")
'Set Flds = oConf.Fields
With oCdo.configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com" 'adresse du serveur smtp
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 'tester 25, 465 ou 587
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True 'Utilise une connection SSL (True or False)
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 40
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 '0 : pas d'authentification, 1 : authentification basique
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "MY GMAIL" 'identifiant de messagerie
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "MY PASSWORD" 'mot de passe de messagerie
.Update
End With
With oCdo
.Subject = "Votre facture" ' objet du message
.From = "MY GMAIL" ' adresse de l'expéditeur
.To = destinataire ' adresse du destinataire
.BCC = "" ' en copie cachée pour conserver trace
.HtmlBody = strHtml ' corps du message HTML
'.AddAttachment (attachement) ' ajout de pièce jointe
.MDNrequested = True
.Send
End With
Set oCdo = Nothing
Next n
End Sub
It's due to the line : .MDNrequested = True
If it is set to false or missing, it works.
I have the same problem. Excel restarts after the first .send when setting MDN to "True". The e-mail is still sent and asks for send a "reception feedback".
BR