Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel VBA-自动创建工作表和插入图片_Excel_Vba_Image - Fatal编程技术网

Excel VBA-自动创建工作表和插入图片

Excel VBA-自动创建工作表和插入图片,excel,vba,image,Excel,Vba,Image,我正在用VBA(Excel)编写代码,选择一个文件夹的路径,然后运行代码,列出该文件夹中的所有图像,然后开始创建工作表以插入该图片(6个按工作表),然后创建更多工作表,直到文件夹中的所有图像都插入其中。问题是。我使用的代码只允许我插入最多50个图像,创建最多9个工作表。我希望在这段代码中进行一些更新,以添加多达1000张图像或150张工作表 有人能帮我吗 谢谢 请参阅下面我正在使用的代码 Sub-LoopThroughFiles() 物体的暗度 作为对象的文件夹的尺寸 作为对象的文件的尺寸 作为

我正在用VBA(Excel)编写代码,选择一个文件夹的路径,然后运行代码,列出该文件夹中的所有图像,然后开始创建工作表以插入该图片(6个按工作表),然后创建更多工作表,直到文件夹中的所有图像都插入其中。问题是。我使用的代码只允许我插入最多50个图像,创建最多9个工作表。我希望在这段代码中进行一些更新,以添加多达1000张图像或150张工作表

有人能帮我吗

谢谢

请参阅下面我正在使用的代码

Sub-LoopThroughFiles()
物体的暗度
作为对象的文件夹的尺寸
作为对象的文件的尺寸
作为整数的Dim I
Set of so=CreateObject(“Scripting.FileSystemObject”)
文件夹集=oFSO.GetFolder(范围(“E15”))
对于oFolder.Files中的每个文件
单元格(I+2,13)=文件名
I=I+1
下一个文件
”“是的
列(“O:O”)。选择
选择。复制
列(“P:P”)。选择
Selection.Paste特殊粘贴:=xlPasteValues,操作:=xlNone,SkipBlank_
:=假,转置:=假
Application.CutCopyMode=False
范围(“I15”)。选择
'创建工作表
'
变暗P为长
整数形式的数字
将xName设置为字符串
将xActiveSheet设置为工作表
工作表(“报告”)。选择
Ce28=范围(“I28”).值
出错时继续下一步
Application.ScreenUpdating=False
图纸(“模型”)。可见=真实
图纸(“模型”)。选择
设置xActiveSheet=ActiveSheet
xNumber=Ce28
对于P=1到xNumber
xName=ActiveSheet.Name
ActiveSheet.copy After:=ActiveWorkbook.Sheets(xName)
ActiveSheet.Name=“0”&P
下一个
xActiveSheet。激活
图纸(“模型”)。可见=假
Application.ScreenUpdating=True
'插入图像
'
工作表(“报告”)。选择
将单元格值P2设置为字符串
CellValuep2=范围(“P2”)。值
将单元格值P3设置为字符串
CellValuep3=范围(“P3”)。值
作为字符串的Dim CellValuep4
CellValuep4=范围(“P4”)。值
Dim CellValuep5作为字符串
CellValuep5=范围(“P5”)。值
作为字符串的Dim CellValuep6
CellValuep6=范围(“P6”)。值
Dim CellValuep7作为字符串
CellValuep7=范围(“P7”).值
Dim CellValuep8作为字符串
CellValuep8=范围(“P8”).值
Dim CellValuep9作为字符串
CellValuep9=范围(“P9”)。值
将单元格值10设置为字符串
CellValuep10=范围(“P10”)。值
Dim CellValuep11作为字符串
CellValuep11=范围(“P11”)。值
Dim CellValuep12作为字符串
CellValuep12=范围(“P12”)。值
将单元格值13设置为字符串
CellValuep13=范围(“P13”)。值
Dim CellValuep14作为字符串
CellValuep14=范围(“P14”)。值
将单元格值15设置为字符串
CellValuep15=范围(“P15”)。值
将单元格值16设置为字符串
CellValuep16=范围(“P16”)。值
Dim CellValuep17作为字符串
CellValuep17=范围(“P17”)。值
将单元格值18设置为字符串
CellValuep18=范围(“P18”)。值
将单元格值19设置为字符串
CellValuep19=范围(“P19”)。值
Dim CellValuep20作为字符串
CellValuep20=范围(“P20”)。值
作为字符串的Dim CellValuep21
CellValuep21=范围(“P21”)。值
Dim CellValuep22作为字符串
CellValuep22=范围(“P22”)。值
Dim CellValuep23作为字符串
CellValuep23=范围(“P23”)。值
作为字符串的Dim CellValuep24
CellValuep24=范围(“P24”)。值
Dim CellValuep25作为字符串
CellValuep25=范围(“P25”)。值
Dim CellValuep26作为字符串
CellValuep26=范围(“P26”)。值
Dim CellValuep27作为字符串
CellValuep27=范围(“P27”)。值
Dim CellValuep28作为字符串
CellValuep28=范围(“P28”)。值
将单元格值29设置为字符串
CellValuep29=范围(“P29”)。值
Dim CellValuep30作为字符串
CellValuep30=范围(“P30”)。值
将单元格值31设置为字符串
CellValuep31=范围(“P31”)。值
Dim CellValuep32作为字符串
CellValuep32=范围(“P32”)。值
Dim CellValuep33作为字符串
CellValuep33=范围(“P33”)。值
将单元格值34设置为字符串
CellValuep34=范围(“P34”)。值
将单元格值35设置为字符串
CellValuep35=范围(“P35”)。值
将单元格值36设置为字符串
CellValuep36=范围(“P36”)。值
Dim CellValuep37作为字符串
CellValuep37=范围(“P37”)。值
Dim CellValuep38作为字符串
CellValuep38=范围(“P38”)。值
将单元格值39设置为字符串
CellValuep39=范围(“P39”)。值
Dim CellValuep40作为字符串
CellValuep40=范围(“P40”)。值
作为字符串的Dim CellValuep41
CellValuep41=范围(“P41”)。值
Dim CellValuep42作为字符串
CellValuep42=范围(“P42”)。值
将单元格值43设置为字符串
CellValuep43=范围(“P43”)。值
Dim CellValuep44作为字符串
CellValuep44=范围(“P44”)。值
将单元格值45设置为字符串
CellValuep45=范围(“P45”)。值
作为字符串的Dim CellValuep46
CellValuep46=范围(“P46”)。值
Dim CellValuep47作为字符串
CellValuep47=范围(“P47”)。值
Dim CellValuep48作为字符串
CellValuep48=范围(“P48”)。值
将单元格值49设置为字符串
CellValuep49=范围(“P49”)。值
出错时继续下一步
表格(“01”)。选择
范围(“B7”)。选择
ActiveSheet.Pictures.Insert(CellValuep2)。选择
ActiveWindow.small向下滚动:=3
Selection.shaperage.Height=172.8
Selection.Placement=xlMoveAndSize
Selection.shaperage.PictureFormat.Crop.PictureWidth=230
Selection.shaperage.PictureFormat.Crop.picturehight=172
Selection.shaperage.PictureFormat.Crop.PictureOffsetX=0
Selection.SHAPERAGE.PictureFormat.Crop.PictureOffsetY=0
Application.commandbar(“格式对象”).Visible=False
Application.commandbar(“格式对象”).Visible=False
Application.commandbar(“格式对象”).Visible=Fals