Hallo M.O.
vielen Dank für die schnelle Antwort. Die Dateinamen sind immer unterschiedlich. Das Verzeichnis, aus dem die Dateien geöffnet werden sollen, sowie das Verzeichnis in das die Daten geschrieben werden sollen steht noch nicht fest. Als dummy könnte c:\rein und c:\raus dienen.
Es sollen immer alle dateien in diesem Verzeichnis geöffnet werden. Das Verzeichnis dient nur dieser Stapelverarbeitung.
Das Makro für den QR Code habe ich hier mal angefügt (natürlich habe ich das nicht selber geschrieben :-) Es ist von StrokeScribe und dort auf der Internetseite frei zugänglich [www.strokescribe.com] )
Sub BulkQR()
Dim wsh As Worksheet
Set wsh = Application.ActiveSheet 'QR codes are generated on the active worksheet
Dim shp As Shape
For Each shp In wsh.Shapes 'Deletes all barcode pictures which are generated previously
If shp.Type = msoPicture And InStr(shp.Name, "BarcodePicture") > 0 Then
shp.Delete
End If
Next
Dim ss As StrokeScribeClass 'Invisible COM server
Set ss = CreateObject("STROKESCRIBE.StrokeScribeClass.1")
ss.Alphabet = QRCODE
pict_path = Environ("TEMP") + "\bar.wmf" 'A temporary file for pictures
Row = 1
Do
Dim data As String
data = wsh.Cells(Row, 2) 'Data for barcodes is taken from the first column
If Len(data) = 0 Then Exit Do 'The code will stop execution on first empty cell occurrence
ss.Text = data
rc = ss.SavePicture(pict_path, WMF, 1440, 1440) 'A 1x1 inch QR Code is stored in a temporary file. 1440 TWIPs=1in.
If rc > 0 Then 'Reports the error if SavePicture() call was unsuccessful
MsgBox ss.ErrorDescription
Exit Do
End If
Set qrcode_cell = wsh.Cells(1, 7) 'The cell where the QR Code will be placed
'The rectangle which fits into the cell. QR codes are square in shape.
qrcode_size = Application.Max(qrcode_cell.Width, qrcode_cell.Height)
'Barcode picture is loaded from file and centered in the cell:
Set shp = wsh.Shapes.AddPicture(pict_path, msoFalse, msoTrue, _
qrcode_cell.Left + (qrcode_cell.Width - qrcode_size) / 2, _
qrcode_cell.Top + (qrcode_cell.Height - qrcode_size) / 4, _
qrcode_size, qrcode_size)
'Each picture is named as BarcodePictureN, where N is 1,2,3...
'So the pictures can be easily removed next time
shp.Name = "BarcodePicture" & Format(Row)
Row = Row + 1 'Going to the next worksheet row
Loop
Kill pict_path 'We don't need the temporary picture file any more
Set ss = Nothing 'Deletes the barcode COM object
End Sub
Beste Grüße
QRMan