excel 从单元格值设置页眉/页脚并将字体设置为条形码

svmlkihl  于 2023-06-25  发布在  其他
关注(0)|答案(1)|浏览(120)

我需要一个条形码生成的页眉或页脚是基于单元格B5中的数值。此值将有所不同。我可以让单元格值填充或条形码字体显示与设置值,但不能让它做这两件事。请帮助和建议是赞赏。

Sub barcode() 
    ' this one works for the value

    With ActiveSheet.PageSetup
        .CenterHeader = Range("B5").Value    
    End With
End Sub


Sub test() ' this one works great for the font
    With ActiveSheet.PageSetup
        .LeftHeader = ""
        .CenterHeader = "&""IDAutomationHC39M Free Version,Regular""rw"
     End With
End Sub


Sub test2() ''Trying to put them together though just clears the header completely 
    With ActiveSheet.PageSetup
        .LeftHeader = ""
        .CenterHeader = "&""IDAutomationHC39M Free Version,Regular" & Range("B5").Value
    End With
End Sub
iq0todco

iq0todco1#

我没有这种字体,但当我试图设置我的标题与

.CenterHeader = "&""Arial" & Range("B5").Value

它清除了报头-即重现了你的问题实验让我发现

.CenterHeader = "&""Arial""&14" & Range("B5").Value

换句话说-你需要给予它一个大小以及字体名称(和文本)

相关问题