Niceform – Exporting Label as Graphic

Label printing integration (NiceWatch middleware and ActiveX programming interface)

Moderators: Georges, milos, NiceLabel Support Team

Post Reply
mattw22
Newcomer
Posts: 4
Joined: Mon Feb 09, 2015 8:17 am

Niceform – Exporting Label as Graphic

Post by mattw22 » Mon Feb 09, 2015 8:22 am

I’m using the following VB Script to export label previews as JPG’s. A user selects the part number from an excel table and then runs the script. My issue is I want the selected part # from the table to be inserted as the filename. Right now it’s just a generic “label.jpg” for every image exported instead of 33432.jpg. I’m using niceform 5.4.

Dim ID, Result, LabelIntf, Nice
LabelFileName = Path & "label.lbl"
Set Nice = CreateObject("NiceLabel5.Application")
Set LabelIntf = Nice.LabelOpenEx(LabelFileName)
Result = LabelIntf.GetLabelPreviewEx(Path & "label" & CStr(Counter) & ".jpg", 400, 400, 1, 0, False)

User avatar
Saso
NiceLabel
NiceLabel
Posts: 2961
Joined: Mon Sep 04, 2006 8:09 am
Contact:

Re: Niceform – Exporting Label as Graphic

Post by Saso » Tue Feb 10, 2015 2:13 pm

To set the name of the generated image based on the value of some variable, just update the last command in your script. The command GetLabelPreviewEx will generate the image on the disk. It accepts a few parameters, the first one being the file name.

Currently, the file name is defined as Path & "label" & CStr(Counter) & ".jpg".
This will merge value of variable Path with fixed text "label", current value of variable Counter and add ".jpg" at the end.

If you want to provide the file name with some other variable (e.g. the one containing the part number from a database), make sure to reference that variable as the first parameter.

You would do the following:

Code: Select all

Result = LabelIntf.GetLabelPreviewEx(PartNumber & ".jpg", 400, 400, 1, 0, False)
Where PartNumber is the variable with the part number.
You can also include the leading path, if you want to save the images in specified folder, such as:

Code: Select all

Result = LabelIntf.GetLabelPreviewEx("c:\My Images" & PartNumber & ".jpg", 400, 400, 1, 0, False)
or

Code: Select all

Result = LabelIntf.GetLabelPreviewEx(Path & PartNumber & ".jpg", 400, 400, 1, 0, False)
If you have a variable Path specifying the folder name.
Saso Fleiser
Senior Technical Product Specialist

mattw22
Newcomer
Posts: 4
Joined: Mon Feb 09, 2015 8:17 am

Re: Niceform – Exporting Label as Graphic

Post by mattw22 » Sun Feb 15, 2015 9:42 am

Thanks!.. Works Perfect..

Post Reply