我正在学习如何编程,并且正在尝试创建代码以打印带有值的海报。 我写了一个循环来复制一个数字,更新一些公式,然后插入图像。 问题在于,在运行时,仅当我逐步执行代码(F8)时,图像才出现。
我已经尝试使用Application.Wait来延迟代码,但是没有用。
Sub impressão()
Dim lastrow As Integer
lastrow = Planilha4.Cells(203, 2).End(xlUp).Row
Dim i As Integer
Dim T, un, vir1, vir2 As String
myDir = ActiveWorkbook.Path & "\imagens\"
T = ".png"
For i = 4 To lastrow
*' if the line is empty then skip*
If Planilha4.Range("B" & i).Value = Empty Then GoTo continua
*'condition, if the line matches the kind of poster*
If Planilha4.Range("J" & i).Value = Range("cart_ref_tipo_cartaz").Value Then
*'copy the line*
Range("imp_linha").Value = i - 3
*'according to the line, it copies a number e.g 1,98
'un = 1*
un = Range("imp_un")
' vir1 = 9
vir1 = Range("imp_vir1")
' vir2 = 8
vir2 = Range("imp_vir2")
*' here it imports the image un = 1*
ActiveSheet.Shapes.AddPicture Filename:=myDir & un & T, linktofile:=msoFalse,
savewithdocument:=msoTrue, _
Left:=50, Top:=490, Height:=329, Width:=218
*' here it imports the image vir1 = 9*
ActiveSheet.Shapes.AddPicture Filename:=myDir & vir1 & T,
linktofile:=msoFalse, savewithdocument:=msoTrue, _
Left:=340, Top:=490, Height:=150, Width:=99
*' here it imports the image vir2 = 8*
ActiveSheet.Shapes.AddPicture Filename:=myDir & vir2 & T,
linktofile:=msoFalse, savewithdocument:=msoTrue, _
Left:=455, Top:=490, Height:=150, Width:=99
*' print the sheet planilha1*
Planilha1.PrintOut Copies:=Range("imp_copias").Value, IgnorePrintAreas:=False
End If
continua:
Next i
End Sub
有人可以帮助我吗?