【发布时间】:2022-11-21 16:32:02
【问题描述】:
for i in range(1, 100):
data = "Set shp = Sld&i.Shapes.AddPicture(\"C:\Users\223232\Desktop\WfdG\Afdr\ddd.png\",msoFalse, msoCTrue, l, t, w, h)"
f.write(data)
我要制作测试文件,因为我觉得在 vba 中键入代码很无聊。 但是这句话一直显示错误。我该如何修改这段代码?
我想放
Set shp = Sld&i.Shapes.AddPicture(\"C:\Users\223232\Desktop\WfdG\Afdr\ddd.png\",msoFalse, msoCTrue, l, t, w, h)
“数据”中的这句话
我试过\\输入\但是不行,可能还有其他问题
【问题讨论】:
-
你好,欢迎光临。请不要标记不相关的语言。
-
您需要转义字符串中的反斜杠:
"Set shp = Sld&i.Shapes.AddPicture(\"C:\\Users\\223232\\Desktop\\WfdG\\Afdr\\ddd.png\",msoFalse, msoCTrue, l, t, w, h)"。使用原始字符串会更容易:r'Set shp = Sld&i.Shapes.AddPicture("C:\Users\223232\Desktop\WfdG\Afdr\ddd.png",msoFalse, msoCTrue, l, t, w, h)' -
您好,您是否需要将“&i”中的“i”替换为循环计数器的值?
标签: printing