Posts Tagged ‘ coding ’

barcode from product id using vba in excel (แสดง barcode ตาม product id ใน excel)

บางครั้งเราต้องการแสดง Product ID. ใน Excel  เป็น Barcode เพื่อให้สามารถ Print

ออกมาและใช้กับเครื่องยิง Barecode ได้ ผมได้แสดงวิธีการสร้าง Barcode ใน Excel ใน VDO

ครั้งต่อไปจะ Share Project ให้ Download ครับ

insert product’s picture using vba in excel (ดึงรูปภาพสินค้าแสดงใน Excel ตาม product id)

หลายครั้ง คนที่ขอ Report จากเรา ต้องการให้ดึงข้อมูลใน Database แล้ว

ส่งเป็น File Excel กลับไป และมักจะต้องการรูปสินค้าแสดงใน Excel ด้วย

ผมได้ทำเป็น File ตัวอย่างไว้ให้ Download sample insert product picture using vba in excel

หรือทำตาม VDO ด้านล่างนี้  โดย Copy VBA ไปไว้ที่ Sheet ที่ต้องการให้แสดงรูปภาพ ซึ่ง

ตาม VDO นี้คือ Sheet1

————————VBA—————————

Dim i As Integer
Dim sFilename As String
Dim bcontinue As Boolean
Dim spath As String

Sub Attempt1()
On Error Resume Next

‘spath = “\\192.168.0.45\Picture\ProductPic\”

spath = “D:\Vdo_Capture\ProductPic\”

i = 2

bcontinue = True

While bcontinue
sFilename = Worksheets(1).Cells(i, 2).Value
If sFilename = “” Then
bcontinue = False
Else

‘Set Position Pic A = 1

Cells(i, 1).Select
ActiveSheet.Pictures.Insert(spath + sFilename + “S1.jpg”).Select
Selection.ShapeRange.LockAspectRatio = msoFalse
Selection.ShapeRange.Height = 50
Selection.ShapeRange.Width = 50
i = i + 1
End If
Wend

End Sub

—————————END———————————-