打印条形码单元格以及相邻单元格

时间:2015-01-06 12:34:56

标签: excel vba excel-vba printing

我在Excel 2013中有一个宏,如下所示:

Sub PrntCells()
Dim rng As Range, rngArea As Range, strCell As String

Set rng = Selection

With ActiveSheet.PageSetup
    .Zoom = False
    .FitToPagesWide = 1
    .FitToPagesTall = 1
    .LeftMargin = Application.InchesToPoints(0)
    .RightMargin = Application.InchesToPoints(0)
    .TopMargin = Application.InchesToPoints(0)
    .BottomMargin = Application.InchesToPoints(0)
    .HeaderMargin = Application.InchesToPoints(0)
    .FooterMargin = Application.InchesToPoints(0)
    .CenterHorizontally = True
    .CenterVertically = True
    .Orientation = xlPortrait
    .LeftHeader = ""
    .LeftFooter = ""
End With

'Copy each selection
For Each rngArea In rng.Areas
    For Each cell In rngArea
        cell.PrintOut Copies:=1
        cell.Offset(0, 1).PrintOut Copies:=1
    Next cell
Next rngArea


Application.DisplayAlerts = True
rng.Parent.Activate

End Sub

我正在使用插件为我生成实际的Code128条形码,并且工作正常,看起来像这样:

Excel

我有设置,所以用户可以选择一系列代码并运行宏,每个条形码都从条形码打印机自己的标签上出来,但他们也希望得到条形码和条形码右边的单元格在标签上,它是项目描述。

有没有办法做到这一点?我很难让它在1标签上打印两个单元格。

我非常感谢任何帮助,我不是Excel专家,这是我第一次尝试在Excel中使用宏。

0 个答案:

没有答案