JustJerry2C
New Member
- Joined
- Aug 21, 2017
- Messages
- 16
Hi Everyone,
I have a file that I keep updating. I've added new coding which I've pieced together from here and now need to do a SaveAs function for Macro enabled. However, since trying to do this, the 'new' file keeps wanting to open, and I don't want that, as I am looping through an array to save multiple files. Before I had all the coding, this used to work just fine. Is there a way to save a file macro-enabled without it opening automatically? My ACTIVEWORKBOOK.CLOSE is not working. (Note: I previously was able to save with the .xlsx extension)
Not sure what I'm missing. I found the FileFormat:=52 here, which helped create the new file.
I have a file that I keep updating. I've added new coding which I've pieced together from here and now need to do a SaveAs function for Macro enabled. However, since trying to do this, the 'new' file keeps wanting to open, and I don't want that, as I am looping through an array to save multiple files. Before I had all the coding, this used to work just fine. Is there a way to save a file macro-enabled without it opening automatically? My ACTIVEWORKBOOK.CLOSE is not working. (Note: I previously was able to save with the .xlsx extension)
Not sure what I'm missing. I found the FileFormat:=52 here, which helped create the new file.
Code:
For i = 1 To cntPrint 'Set Counter to cycle through all students
If Range(SID) = "Y" Or Range(SID) = "y" Then
For Each wsc In Worksheets
If wsc.CodeName = "S" & i & "ReportCard" Then
Set myrws = wsc
Exit For
End If
Next wsc
For Each wsc In Worksheets
If wsc.CodeName = "S" & i & "CheckList" Then
Set mycws = wsc
Exit For
End If
Next wsc
cntStudent = cntStudent + 1
txtSheet = myrws.Name 'Assign sheet1 selected name to use for file name on next line
strSaveName = OutputFolderName & ControlSheet.Range("B" & SIDN).Value & " " & ControlSheet.Range("C" & SIDN).Value
mycws.Select (False)
txtSheet2 = mycws.Name 'Assign sheet2 with selected checklist sheet name
Sheets(Array(txtSheet, txtSheet2, txtSheet3, txtSheet4, txtSheet5, txtSheet6)).Copy
Worksheets(4).Visible = xlSheetHidden
Worksheets(3).Visible = xlSheetHidden
Worksheets(2).Visible = xlSheetHidden
Worksheets(1).Visible = xlSheetHidden
ActiveWorkbook.SaveAs strSaveName, FileFormat:=52 'Save new file
ActiveWorkbook.Close 'close new file
End If
'Advance to Next Student
SIDN = SIDN + 1
SID = "D" & SIDN
SIDB = "B" & SIDN
SIDC = "C" & SIDN
Next i