Barcode 128 in Grafik umwandeln
#7
Hallo N...;-),

Das Makro muss man natürlich für Code 128 umstricken.
Unter X7 läuft es:

[Bild: code1289aj63.gif]

Das Makro codiert allerdings Umlaute falsch.
Wenn das noch nachgerüstet werden soll, müsste man wissen,
ob der Scanner FNC4 beherrscht oder Umlaute anders umgewandelt werden müssen.

Code:
Sub Code128()
    Dim Text As String
    Dim TempPfad As String
    Dim ZintPfad As String
    Dim Skalierung As String
    Dim Befehl As String
    
    ActiveDocument.Unit = cdrMillimeter
    
    ZintPfad = WoIstZint
    TempPfad = Environ("TEMP") & "\"
    
    Skalierung = "1.5"
    a = Chr(34)
    If ActiveDocument.Selection.Shapes.Count = 0 Then
        MsgBox "nichts ausgewählt!", vbExclamation
        Exit Sub
    End If
    If ActiveDocument.Selection.Shapes(1).Type = cdrTextShape Then
        Text = ActiveDocument.Selection.Shapes(1).Text.Story 'Text des selektierten Objekts
        Text = Trim(Text)
        If Text <> "" Then
            Text = Replace(Text, a, "\" & Chr(34)) 'Zollzeichen maskieren
            Text = Chr(34) & Text & a
            Text = Replace(Text, Chr(13), "\n") ' Zeilenumbrüche ersetzen
            Text = Replace(Text, Chr(11), "\n") ' Zeilenumbrüche ersetzen
            Befehl = _
            a & ZintPfad & "zint" & a _
            & " " & a & "-o" & a & " " _
            & a & TempPfad _
            & "temp.eps" & a _
            & " --binary -b 60" _
            & " --scale=" & Skalierung _
            & " -d " _
            & Text
'            Debug.Print Befehl
            warte Befehl 'Ausführen und warten bis Zint fertig ist
            If DateiVorhanden(TempPfad & "temp.eps") Then
                epsImport TempPfad & "temp.eps" 'Importieren
                Kill TempPfad & "temp.eps" 'temporäre Datei löschen
            Else
                MsgBox "Codierungsfehler", vbExclamation
                Exit Sub
            End If
            Else
            MsgBox "Keinen Text gefunden", vbExclamation
        End If
        Else
        MsgBox "Keinen Text gefunden", vbExclamation
    End If
End Sub

Sub warte(ByVal strPath As String)
    Dim WshShell As Object
    Set WshShell = CreateObject("WScript.Shell")
    WshShell.Run strPath, 7, 1
    Set WshShell = Nothing
End Sub

Function DateiVorhanden(Datei As String) As Boolean
    Dim FS As Object
    Set FS = CreateObject("Scripting.FileSystemObject")
    DateiVorhanden = FS.FileExists(Datei)
    Set FS = Nothing
End Function

Sub epsImport(Datei As String)
    Dim cx As Double, ct As Double
    Dim s As Shape
    cx = ActiveShape.CenterX
    ct = ActiveShape.TopY
    Dim impopt As StructImportOptions
    Set impopt = CreateStructImportOptions
    impopt.MaintainLayers = True
    Dim impflt As ImportFilter
    Set impflt = ActiveLayer.ImportEx(Datei, cdrPSInterpreted, impopt)
    impflt.Finish
    ActiveShape.CenterX = cx
    ActiveShape.BottomY = ct
    For Each s In ActiveShape.Shapes
        If s.Type = cdrTextShape Or s.Fill.UniformColor.RGBValue <> 0 Then
            s.Delete
        End If
    Next
    With ActiveShape
        .Shapes.All.Combine
        .Ungroup
    End With
    ActiveSelection.Shapes.All.RemoveFromSelection
End Sub

Function WoIstZint() As String
    On Error GoTo fehler
    Dim WshShell As Object
    Set WshShell = CreateObject("WScript.Shell")
    If DateiVorhanden("C:\Program Files (x86)\Zint\zint.exe") Then
        WoIstZint = "C:\Program Files (x86)\Zint\"
        Set WshShell = Nothing
        Exit Function
    Else
        WoIstZint = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\qtZint.exe\Path") & "\"
        Set WshShell = Nothing
        Exit Function
    End If
fehler:
    WoIstZint = ""
End Function

Gruß

Koter
Zitieren



Nachrichten in diesem Thema
Barcode 128 in Grafik umwandeln - von nowa - 09.12.2016, 16:33
Barcode 128 in Grafik umwandeln - von OsCor - 10.12.2016, 10:32
Barcode 128 in Grafik umwandeln - von nowa - 11.12.2016, 19:17
Barcode 128 in Grafik umwandeln - von norre - 11.12.2016, 21:57
Barcode 128 in Grafik umwandeln - von nowa - 11.12.2016, 22:56
Barcode 128 in Grafik umwandeln - von norre - 11.12.2016, 23:18
Barcode 128 in Grafik umwandeln - von koter - 12.12.2016, 01:51
Barcode 128 in Grafik umwandeln - von nowa - 12.12.2016, 10:35
Barcode 128 in Grafik umwandeln - von Omicron - 17.12.2016, 23:19
Barcode 128 in Grafik umwandeln - von Suc - 18.12.2016, 10:49
Barcode 128 in Grafik umwandeln - von norre - 18.12.2016, 12:59
Barcode 128 in Grafik umwandeln - von Omicron - 18.12.2016, 22:03
Barcode 128 in Grafik umwandeln - von mvm - 19.12.2016, 00:00
Barcode 128 in Grafik umwandeln - von nowa - 19.12.2016, 16:55
Barcode 128 in Grafik umwandeln - von nowa - 19.12.2016, 17:06
Barcode 128 in Grafik umwandeln - von Omicron - 20.12.2016, 00:52
Barcode 128 in Grafik umwandeln - von nowa - 21.12.2016, 18:41

Möglicherweise verwandte Themen...
Thema Verfasser Antworten Ansichten Letzter Beitrag
  Corel Draw - Schrift Quicksand nach Umwandeln in Kurven nicht plottbar annalotta 1 1.864 15.02.2024, 13:57
Letzter Beitrag: Piet
  Grafik beim Export für das Web unscharf AndreasMi 1 913 17.06.2023, 12:02
Letzter Beitrag: koter
  Grafik per Makro Exportieren Chrisbeee 10 2.177 10.02.2023, 00:54
Letzter Beitrag: Chrisbeee
  Kurven wieder in Text umwandeln Karthagos 18 4.869 30.04.2022, 12:24
Letzter Beitrag: koter
  DSF-Dateien in DXF oder DRW umwandeln? Ralf Ham 14 6.897 04.01.2020, 09:30
Letzter Beitrag: Unkraut
  Objekt in Kontur umwandeln (ich kann die Farbe nicht ändern) Roelli 1 1.701 25.11.2018, 18:03
Letzter Beitrag: norre
  cdr in pdf umwandeln Jott Kaa 2 1.573 29.07.2018, 10:25
Letzter Beitrag: Jott Kaa
  Warum macht Corel Trace_9 Linien um die Grafik?? diddytil 5 1.749 29.05.2018, 20:03
Letzter Beitrag: norre
  1 von 3 Druckern "vergisst" Teile einer Grafik mc_oyzo 3 1.854 07.01.2018, 22:15
Letzter Beitrag: mc_oyzo
  RGB-Farbe möglichst präzise in CMYK umwandeln OsCor 8 4.859 25.10.2017, 12:08
Letzter Beitrag: OsCor