D
Denise Pollock
I have a macro that takes a copy of one sheet in a workbook pastes the values
in a new sheet in a new workbook, then does a "save as" in a location on the
network. The macro works fine, however I have one user that keeps making the
macro malfunction. Because he is saving on a distant network it takes a
while for the macro to complete. I have ScreenUpdating and EnableEvents
turned off while the macro is running. Somehow, he is managing to activate
the main workbook while the macro is running which causes the entire
mainworkbook to be saved on the network, and he is left with book1 open his
computer. I have no idea how he is managing to do this as he assures me he
is not clicking anything. It's not the macro cause it is working fine for 10
other users. However, is there a way I can change it so it is specifying the
new workbook when it does the save and closes the file instead of using
active workbook?
Here is the code:
ActiveWorkbook.Save
Sheets("Sheet1").Select
Sheets("Sheet1").Copy
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveWorkbook.SaveAs Filename:= _
strSourceFolder & "\TEST.xls", _
FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkbook.Close
in a new sheet in a new workbook, then does a "save as" in a location on the
network. The macro works fine, however I have one user that keeps making the
macro malfunction. Because he is saving on a distant network it takes a
while for the macro to complete. I have ScreenUpdating and EnableEvents
turned off while the macro is running. Somehow, he is managing to activate
the main workbook while the macro is running which causes the entire
mainworkbook to be saved on the network, and he is left with book1 open his
computer. I have no idea how he is managing to do this as he assures me he
is not clicking anything. It's not the macro cause it is working fine for 10
other users. However, is there a way I can change it so it is specifying the
new workbook when it does the save and closes the file instead of using
active workbook?
Here is the code:
ActiveWorkbook.Save
Sheets("Sheet1").Select
Sheets("Sheet1").Copy
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveWorkbook.SaveAs Filename:= _
strSourceFolder & "\TEST.xls", _
FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkbook.Close