I send the whole thing instead of half a code.
Dymo Addin is the VBS way of calling DYMO Labelwriter software.
If you get script error (windows) you need to reinstall DYMO Labelwriter software.
And by the way. Dymo v7 is much much better than v8. I have been in contact with their support sooooo much and they admit to a lot of bugs and problems with the SDK. Its all documented in their forum, and they also advice coders to use v7 (which actually does its job). If you have dymo label writer 450 you need a patch to be able to use v7.
Here is the entire code, both PC and Mac:
Code: Select all
Procedure dymo_printlabel(text.s)
text.s=ReplaceString(text.s,"<p>","")
text.s=ReplaceString(text.s," "," ")
text.s=ReplaceString(text.s,"<br>",#CRLF$)
text.s=ReplaceString(text.s,"</p>",#CRLF$)
text.s=ReplaceString(text.s,"<html>","")
text.s=ReplaceString(text.s,"</html>","")
text.s=ReplaceString(text.s,"<body>","")
text.s=ReplaceString(text.s,"</body>","")
text.s=ReplaceString(text.s,"<head>","")
text.s=ReplaceString(text.s,"</head>","")
text.s=ReplaceString(text.s,"<strong>","")
text.s=ReplaceString(text.s,"</strong>","")
CompilerIf #PB_Compiler_OS=#PB_OS_MacOS
text.s=ReplaceString(text.s,#CR$,Chr(34)+" & crlf & "+Chr(34))
text.s=ReplaceString(text.s,Chr(10),"")
a.s="try"+#CRLF$
a.s+"set crlf to (ASCII character 13) & (ASCII character 10)"+#CRLF$
a.s+"set the_address To "+Chr(34)+text.s+Chr(34)+#CRLF$
a.s+"tell application "+Chr(34)+"DYMO Label"+Chr(34)+#CRLF$
a.s+"set object text of address 1 To the_address"+#CRLF$
a.s+"set content of address 1 To the_address"+#CRLF$
a.s+"printLabel2"+#CRLF$
a.s+"End tell"+#CRLF$
a.s+"End try"+#CRLF$
b.s=COCOA_AppleScript(a.s)
Debug "Returned result from APPLESCRIPT:"+b.s
CompilerElse
text.s=ReplaceString(text.s,Chr(10),"")
If Left(text.s,1)=Chr(10)
text.s=Right(text.s,Len(text.s)-1)
EndIf
text.s=ReplaceString(text.s,#CR$,Chr(34)+"+chr(10)+"+Chr(34))
fil.l=CreateFile(#PB_Any,GetTemporaryDirectory()+"dymo.vbs")
WriteStringN(fil.l,"Dim DymoAddIn")
WriteStringN(fil.l,"Dim DymoLabel")
WriteStringN(fil.l,"Set DymoAddIn = CreateObject("+Chr(34)+"DYMO.DymoAddIn"+Chr(34)+")")
WriteStringN(fil.l,"Set DymoLabel = CreateObject("+Chr(34)+"DYMO.DymoLabels"+Chr(34)+")")
If FileSize("c:\label.LWT")>3
WriteStringN(fil.l,"DymoAddIn.Open "+Chr(34)+"C:\label.LWT"+Chr(34))
EndIf
WriteStringN(fil.l,"DymoLabel.SetAddress 1,"+Chr(34)+text+Chr(34))
WriteStringN(fil.l,"DymoAddIn.Print 1, TRUE")
CloseFile(fil.l)
RunProgram(GetTemporaryDirectory()+"dymo.vbs","","",#PB_Program_Hide)
CompilerEndIf
EndProcedure
And I don't mean at all to take focus from PureDYMO. Just needed a cross platform way of printing labels myself, that worked in thread safe mode and this did its job so..