I am new to excel macros, I am working on creating a macro which needs to format the cells and also to generate the bar code for column A. Created a function Code128() to convert the string in to bar code as given in the blog and it works fine.
I am using them in the macros I am creating like below
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$1"
.PrintGridlines = True
.Orientation = xlLandscape
.PaperSize = xlPaperA4
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = False
End With
Columns("A").ColumnWidth = 10
For Each Target In Range("A1", Range("A" & Rows.Count).End(xlUp))
If Target.Value <> vbNullString Then
Target.Value = PERSONAL.XLSB!Code128(Target.Value)
Target.Resize(, 12).WrapText = True
Target.Font = "Code 128"
End If
Next
Next
But when I run the macro on the excel I am getting the run time error like
答案 0 :(得分:1)
您应该能够使用Application.Run
来评估另一个工作簿中存在的函数。格式是:
Target.Value = Application.Run("PERSONAL.XLSB!Module2.Code128", Target.Value)
或更一般地说:
= Application.Run(workbookname$ & "!" & modulename & "." & functionname, args())
除此之外,您可以在Book1中Add a reference to Personal.xlb。