Hello all!
I use the code below to "export" selected sheets from a workbook as excel, csv, txt, etc. (on the saveas fileformat differs).
Just recently, I've begun to have issues with the activewindow focus. I believe it's speed-related within a Novell server environment.
The problem is, sporadically (but not always), after the selectedsheets.copy command (below), the activeworkbook is still the SOURCE (i.e. ThisWorkbook). USUALLY, the activeworkbook is the NEW workbook created by the copy.
(1) Is their a way to test that the .copy is done? (I'm assuming it's an asynchronus task due to this problem).
I thought about looping (with a DoEvents or Sleep API) until the ActiveWorkbook does NOT = Thisworkbook.
(2) Is their a better way to get accomplish my goal?
THANKS !
Innov
I use the code below to "export" selected sheets from a workbook as excel, csv, txt, etc. (on the saveas fileformat differs).
Just recently, I've begun to have issues with the activewindow focus. I believe it's speed-related within a Novell server environment.
The problem is, sporadically (but not always), after the selectedsheets.copy command (below), the activeworkbook is still the SOURCE (i.e. ThisWorkbook). USUALLY, the activeworkbook is the NEW workbook created by the copy.
(1) Is their a way to test that the .copy is done? (I'm assuming it's an asynchronus task due to this problem).
I thought about looping (with a DoEvents or Sleep API) until the ActiveWorkbook does NOT = Thisworkbook.
(2) Is their a better way to get accomplish my goal?
THANKS !
Innov
Code:
'----------------------------------------------------------------------------
'Copy selected sheets to a temporary wkbk and copy values to remove formulas.
'Then break any remaining links (pics, etc.)
'The temp wkbk will be "saved as" excel, cvs, txt and/or html
'----------------------------------------------------------------------------
ActiveWindow.SelectedSheets.Copy
'HERE IS WHERE THE ACTIVEWORKBOOK ISN'T ALWAYS THE NEWLY CREATED WORKBOOK.
For Each ws In Worksheets
Sheets(ws.Name).Activate
Sheets(ws.Name).Unprotect
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range("A1").Select
Next ws
Call Break_Links
'-----------------------------------------------------------------------------