Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/25.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/16.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 在多个关闭的工作簿中取消隐藏同一命名工作表_Excel_Vba - Fatal编程技术网

Excel 在多个关闭的工作簿中取消隐藏同一命名工作表

Excel 在多个关闭的工作簿中取消隐藏同一命名工作表,excel,vba,Excel,Vba,我希望在多个工作簿中取消隐藏完全相同的命名工作表。该工作表称为管理导出。所有工作簿都在同一目录中 我环顾四周,并没有找到完全符合这一点的东西,一直试图在有限的编码背景下解决它,并已接近。这很接近: 所以我用这个,但需要实际的 Sub unhide() Dim myfiles, wb As Workbook, ws As Worksheet myfiles = Dir(Thisworkbook.Path & "\*.xlsx") Do While Len(myfiles)

我希望在多个工作簿中取消隐藏完全相同的命名工作表。该工作表称为管理导出。所有工作簿都在同一目录中

我环顾四周,并没有找到完全符合这一点的东西,一直试图在有限的编码背景下解决它,并已接近。这很接近:

所以我用这个,但需要实际的

Sub unhide()
   Dim myfiles, wb As Workbook, ws As Worksheet
   myfiles = Dir(Thisworkbook.Path & "\*.xlsx")
   Do While Len(myfiles) <> 0
       Debug.Print myfiles
       '~~> Should this be read-only? Or just regular open?
       Set wb = Workbooks.Open(Thisworkbook.Path & "\" & myfiles, , True)
       '~~> This is where I need help with unhiding
       wb.Close False
       Set wb = Nothing '~~> clean up
       myfiles = Dir
   Loop   
End Sub
Sub unhide()
Dim myfiles、wb作为工作簿、ws作为工作表
myfiles=Dir(Thisworkbook.Path&“\*.xlsx”)
Do While Len(我的文件)0
调试。打印我的文件
“~~>这应该是只读的吗?还是只开普通店?
设置wb=Workbooks.Open(thishworkbook.Path&“\”&myfiles,True)
“~~>这是我需要帮助解除隐藏的地方
wb.关闭错误
设置wb=Nothing'~~>清理
myfiles=Dir
环
端接头
提前感谢您的帮助。

Sub unhide()
Sub unhide()
   Dim myfiles, wb As Workbook, ws As Worksheet
   myfiles = Dir(ThisWorkbook.Path & "\*.xlsm")
   Do While Len(myfiles) <> 0
       Set wb = Workbooks.Open(ThisWorkbook.Path & "\" & myfiles, , True)
       Workbooks.Open myfiles
       Sheets("ADMIN_Export").Visible = True
       wb.Close True
       Set wb = Nothing
       myfiles = Dir
   Loop
End Sub
Dim myfiles、wb作为工作簿、ws作为工作表 myfiles=Dir(ThisWorkbook.Path&“\*.xlsm”) Do While Len(我的文件)0 设置wb=Workbooks.Open(thishworkbook.Path&“\”&myfiles,True) 工作簿。打开我的文件 工作表(“管理导出”)。可见=真 wb.Close为真 设置wb=Nothing myfiles=Dir 环 端接头
子取消隐藏()
Dim myfiles、wb作为工作簿、ws作为工作表
myfiles=Dir(ThisWorkbook.Path&“\*.xlsm”)
Do While Len(我的文件)0
设置wb=Workbooks.Open(thishworkbook.Path&“\”&myfiles,True)
工作簿。打开我的文件
工作表(“管理导出”)。可见=真
wb.Close为真
设置wb=Nothing
myfiles=Dir
环
端接头

实际上,这应该是可行的:

Sub unhide()
   Dim myfiles, wb As Workbook, ws As Worksheet

   myfiles = Dir(ThisWorkbook.Path & "\*.xlsm")

   Do While Len(myfiles) <> 0
       Set wb = Workbooks.Open(ThisWorkbook.Path & "\" & myfiles)
       wb.Sheets("ADMIN_Export").Visible = xlSheetVisible

       wb.Save
       wb.Close False
       'or instead of save use wb.Close True

       Set wb = Nothing
       myfiles = Dir
   Loop
End Sub
Sub unhide()
Dim myfiles、wb作为工作簿、ws作为工作表
myfiles=Dir(ThisWorkbook.Path&“\*.xlsm”)
Do While Len(我的文件)0
设置wb=Workbooks.Open(thiswoolk.Path&“\”&myfiles)
工作表(“管理导出”).Visible=xlSheetVisible
wb.保存
wb.关闭错误
'或使用wb.Close True代替保存
设置wb=Nothing
myfiles=Dir
环
端接头

实际上,这应该是可行的:

Sub unhide()
   Dim myfiles, wb As Workbook, ws As Worksheet

   myfiles = Dir(ThisWorkbook.Path & "\*.xlsm")

   Do While Len(myfiles) <> 0
       Set wb = Workbooks.Open(ThisWorkbook.Path & "\" & myfiles)
       wb.Sheets("ADMIN_Export").Visible = xlSheetVisible

       wb.Save
       wb.Close False
       'or instead of save use wb.Close True

       Set wb = Nothing
       myfiles = Dir
   Loop
End Sub
Sub unhide()
Dim myfiles、wb作为工作簿、ws作为工作表
myfiles=Dir(ThisWorkbook.Path&“\*.xlsm”)
Do While Len(我的文件)0
设置wb=Workbooks.Open(thiswoolk.Path&“\”&myfiles)
工作表(“管理导出”).Visible=xlSheetVisible
wb.保存
wb.关闭错误
'或使用wb.Close True代替保存
设置wb=Nothing
myfiles=Dir
环
端接头

您需要打开文件才能执行此操作。这可以在后台的VBA中完成,这样用户就不会看到很多文件被打开,但您必须打开它们。然后请回答您的问题,并显示您尝试过的确切代码,以及您在代码中遇到的卡滞或错误。我们只能在看到您的代码时提供帮助。类似代码的任何链接都无法帮助您。还有,谢谢,这就是我想要的。刚刚更新了问题。您是否研究了如何取消隐藏工作表?应该有数百个这样的例子。然后,您只需在打开工作簿后填写即可。当然,您需要定期(非只读)打开worbook,否则无法保存更改。在关闭工作簿之前,还应保存工作簿,否则更改将丢失。你真的应该试一试,这对初学者来说是件容易的事。如果您有特定的问题,请随时提问。研究提示:您只需要将其与问题中的代码结合起来。谢谢,我可以半手动完成,因为我无法使保存生效。现在一切都好。非常感谢。您需要打开文件才能这样做。这可以在后台的VBA中完成,这样用户就不会看到很多文件被打开,但您必须打开它们。然后请回答您的问题,并显示您尝试过的确切代码,以及您在代码中遇到的卡滞或错误。我们只能在看到您的代码时提供帮助。类似代码的任何链接都无法帮助您。还有,谢谢,这就是我想要的。刚刚更新了问题。您是否研究了如何取消隐藏工作表?应该有数百个这样的例子。然后,您只需在打开工作簿后填写即可。当然,您需要定期(非只读)打开worbook,否则无法保存更改。在关闭工作簿之前,还应保存工作簿,否则更改将丢失。你真的应该试一试,这对初学者来说是件容易的事。如果您有特定的问题,请随时提问。研究提示:您只需要将其与问题中的代码结合起来。谢谢,我可以半手动完成,因为我无法使保存生效。现在一切都好。非常感谢。请注意,
Workbooks.Open myfiles
将打开工作簿两次,因为您已经在
Set wb=Workbooks.Open(thiswoolk.Path&“\”&myfiles,True)
中打开了工作簿,您只需删除使其只读的
True
。它应该是wb.Sheets(“ADMIN_Export”).Visible=xlSheetVisible见我的答案出现错误是因为
wb
以只读方式打开(因为
True
为3ʳ)ᵈ 参数)和
wb.Close True
试图保存该工作簿,但无法只读。请注意,
Workbooks.Open myfiles
将打开工作簿两次,因为您已在
Set wb=Workbooks.Open(thishworkbook.Path&“\”&myfiles,True)中打开该工作簿
您只需删除使其成为只读的
True
。它应该是wb.Sheets(“ADMIN_Export”).Visible=xlSheetVisible见我的答案出现错误是因为
wb
以只读方式打开(因为
True
为3ʳ)ᵈ 参数)和
wb.Close True
正在尝试保存它,它无法在只读模式下工作。这