Hello everyone. I have the following problem : I am using a macro that imports of sheets inside my excel file ; sometimes I have to import even 30 sheets , and since the operation is long I wanted to make a userform that the start of the macro says " loading " ; I saw on the net that it was possible to combine the userform animation ( file with .swf ) through enabling shockwave object . The userform if launched in part actually works , the problem comes when loading the userform inside the main macro . In that case, the animation is not working . Maybe because when importing not remain on sheet 1 but you move on sheets imported . I also tried to put " Application.ScreenUpdating = False " , without any results . There is a solution to this problem? Maybe I have something wrong. Thank you in advance to those who will help me .
Attach macro and file demonstration .
Attach macro and file demonstration .
Code:
Option Explicit
Sub COPIA_FOGLIO3()
Dim objfso
Dim initialfoldr$
Dim mfolder
Set objfso = CreateObject("Scripting.FileSystemObject")
initialfoldr$ = "C:\" '<<< Startup folder
With Application.FileDialog(msoFileDialogFolderPicker) 'User input for folder to look at
.InitialFileName = Application.DefaultFilePath & "\"
.Title = "Please select a folder to list Files from"
.InitialFileName = initialfoldr$
.show
If .SelectedItems.Count = 0 Then Exit Sub
mfolder = .SelectedItems(1) & "\"
End With
Dim nomefile As String
Dim wb As Workbook
Dim ws As Worksheet
Dim per As String
Application.ScreenUpdating = False
UserForm1.show vbModeless
UserForm1.Repaint
nomefile = Dir(mfolder & "*.xls*")
Do While nomefile <> ""
If nomefile <> ThisWorkbook.Name Then
Set wb = Application.Workbooks.Open(mfolder & nomefile)
Set ws = wb.Worksheets(1)
ws.Name = Left(nomefile, Len(nomefile) - 4)
ws.Copy After:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count)
wb.Close False
End If
nomefile = Dir
Loop
UserForm1.hide
DoEvents
Application.ScreenUpdating = True 'Unfreeze
MsgBox "Fogli Importati", vbInformation
End Sub