Earn Points & Redeem with attractive offers!
You can earn points, by asking, answering, voting questions and redeem with
attractive offers
. To view various available redemption schemes, please visit
"My Profile".
New User? Sign Up  |  Sign In  |  Help
Barcode support and tutorials from IDAutomation and the community. Click for the BBB Business Review of this Computers Hardware, Software & Services in Tampa FL
Ask
Ask a question. Make sure you select the correct category for the question.
Answer
Like to help others? Then browse through the open questions to answer their questions.
Find
Find answer by browsing the resolved questions.
     
Search for Questions:
My Profile

FulanoNadie

Resolved Questions Bookmark and Share

How to stream a barcode image in Excel

We developed a useful way to stream a barcode image from the Dynamic Barcode Generator Subscription (live online demo) to Excel.

Notes:
• Excel cannot truly put the picture in the cell, but this VBA code adjusts the cells to the image object's height.
• The user must delete the pictures manually.
• The user must reset the row height and width to new data height/width.
• The images are placed directly in the column to the right of the data.
• Feel free to use this code in any way and make any modifications.

To add/change barcode parameters/properties, modify the parameters variable.

To modify the range of cells, change the a2:a10 to a single cell, a different range (a12:a22), or specific cells (a2,a4,a12).

To Implement in Excel:
1. Except for the current worksheet, close all other worksheets (very important).

2. From the standard worksheet view, enter the Visual Basic Editor (VBE):
Windows Instructions
Mac Instructions

3. In the VBE's left-hand panel, choose VBAProject(CurrentWorksheet).

4. From the Excel menu, choose Insert, then Module. A new Modules folder will show, with a new Module underneath (which may be renamed).

5. In the new Module's white space on the right hand side, copy and paste the below VBA code.

6. From the Excel menu, choose File, Save. If prompted, save the worksheet as an Excel macro-enabled workbook (which has the XLSM extension). If this step is not performed, the VBA will not be retained in the workbook, due to Excel security settings.

7. Once the above step has been performed, close the VBE window:
• Modify the range of cells.
• On the Developer tab, under Visual Basic, choose Macros, run IDABCGen.

VBA Macro:

Sub IDABCGen()
Dim cell, parameters, shp As Shape, target As Range
Set KeyCells = ActiveSheet.Range("a2:a10") ' range with names

parameters = "I = JPEG" 'add extra parameters here (it is suggested to keep I = JPEG)

For Each cell In KeyCells
If cell <> "" Then
myurl = "http://www.bcgen.com/demo/linear-dbgs.aspx?" & parameters & "&D=" & cell
filenam = myurl
ActiveSheet.Pictures.Insert(filenam).Select
Set shp = Selection.ShapeRange.Item(1)

With shp
.LockAspectRatio = msoFalse
'.Width = 50 'Adjust width (by trial and error)
'.Height = 50 'Adjust width (by trial and error)
.Cut
End With

Cells(cell.Row, cell.Column + 1).PasteSpecial
End If

'Adjust the rows next to the image objects
For Each Picture In ActiveSheet.DrawingObjects
PictureTop = Picture.Top
PictureLeft = Picture.Left
PictureHeight = Picture.Height
PictureWidth = Picture.Width
For N = 2 To 256
If Columns(N).Left > PictureLeft Then
PictureColumn = N - 1
Exit For
End If
Next N
For N = 2 To 65536
If Rows(N).Top > PictureTop Then
PictureRow = N - 1
Exit For
End If
Next N
Rows(PictureRow).RowHeight = PictureHeight
Columns(PictureColumn).ColumnWidth = PictureWidth * (54.29 / 288)
Picture.Top = Cells(PictureRow, PictureColumn).Top
Picture.Left = Cells(PictureRow, PictureColumn).Left
Next Picture

Next

End Sub


Operating System: Windows, Mac

Application: Windows Excel (2003+), Mac Excel (2004 and 2011+)

01-20-15     1032 day(s) ago     Views: 2369

    Report Abuse

 

James

Best Answer

Thank you for posting this code. We definitely appreciate the additional insight - it will be useful to many clients.

Support Note:
IDAutomation cannot provide consulting services, troubleshoot, or provide implementation support for the above custom source code, as it is outside the scope of support.



Posted 1032 day(s) ago

()
()
  Report Abuse
 
   Find Interesting  
   Email to Others  
   Bookmark  
   Subscribe to Answer Alert  
No comments yet.     Be the first to comment.

Email this question link to friends
You must enter an email address, if name is entered or vice-versa for each friend.
Friend #1 -
Friend #2 -
Friend #3 -
Friend #4 -
Friend #5 -
  Your comment on this question
  |         |  
bold  italic  underline  strike       big  small       superscript  subscript 
  Allows to add a link. Added links would only be converted to actual clickable link, when the domain of the link is white-listed by administrator.
Caption :
Link URL :
(Must starts with "http://")
Add  |   Cancel
  Allow to insert an image. Must be among the following file types - *.jpg, *.gif, *.png & *.bmp.
Image Url :   Upload New
(Image url must always starts with " http:// ")
Width : pixels
(Must not be greater than 450px. Enter 0px for no resize)
Add  |   Cancel
  Allow to insert YouTube video. Insert the video embed code.
Embed Code :
Add  |   Cancel
Up to 5000 Characters are allowed. Current Count: 0
  Your comment on this answer
  |         |  
bold  italic  underline  strike       big  small       superscript  subscript 
  Allow you to add a link. Added links would only be converted to actual clickable link, when the domain of the link is white-listed by administrator.
Caption :
Link URL :
(Must start with "http://")
Add  |   Cancel
  Allow to insert an image. Must be among the following file types - *.jpg, *.gif, *.png & *.bmp.
Image Url :   Upload New
(Image url must always start with " http:// ")
Width : pixels
(Must not be greater than 450px. Enter 0px for no resize)
Add  |   Cancel
  Allow to insert YouTube video. Insert the video embed code.
Embed Code :
Add  |   Cancel
Up to 5000 characters are allowed. Current Count: 0

You may answer and comment on any thread according to the Terms and Conditions.

 © Copyright 2017 IDAutomation.com, Inc., All Rights Reserved. Legal Notices.

 Barcode Fonts | Components | Scanners | Support | Contact Us
Training Videos on YouTube Join us on Google Plus Join us on LinkedIn Follow us on Twitter Like us on Facebook