我有一个五张工作簿。每张纸都定义了一个打印区域,我想在打印区域的右上角插入艺术字。我正在使用下面的代码。问题是形状出现在工作表的任何位置,而不是打印区域的右上角。有什么建议吗?
Sub test()
Dim col As String, row As Long, rng As Range
Dim sht As Worksheet, str_val As String
Dim shp As Shape
For Each sht In ThisWorkbook.Sheets
str_val = sht.Name & vbNewLine & "YM" & vbNewLine & Date
sht.Activate
If ActiveSheet.PageSetup.PrintArea <> vbNullString Then
col = Split(ActiveSheet.PageSetup.PrintArea, "$")(3)
row = Range(ActiveSheet.PageSetup.PrintArea).Cells(1).row
str_val = sht.Name & vbNewLine & "YM" & vbNewLine & Date
Set rng = Cells(row, col)
Set shp = ActiveSheet.Shapes.AddTextEffect(msoTextEffect28, str_val, "+mn-lt", 20, msoTrue, msoFalse, rng.Left, rng.Top)
End If
Next
End Sub
感谢您调查它。