Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
activate workbook
My VBA for Excel code (in workbook WB1) generates some data, writes it to a
worksheet (WS1), creates a new workbook (WB2), moves the worksheet (WS1) to WB2 and then activates WB1. But the taskbar appears to indicate that WB2 is active when WB1 is actually the active workbook. I can't see that any problem except for this appearance. Any thoughts? What would I do to make it appear that WB1 is active? I've uploaded a screen print. http://www.kevinjperez.com-a.googlep...m/ExcelOut.JPG Thanks. Kevin |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
activate workbook
The code:
Sub MoveWorksheets() Dim TestSheet As Worksheet, NewBook As Workbook MasterSheet$ = "Plant_Mon" MasterFullName$ = MasterWorkbook.FullName MasterFileName$ = GetFilename(MasterFullName$) MasterPath$ = GetPath(MasterFullName$) Set NewBook = Workbooks.Add NewBook.SaveAs Filename:=strNewFullName MasterWorkbook.Activate For Each sh In ActiveWorkbook.Worksheets ThisSheetName$ = sh.Name For LoopAP% = 1 To 18 SheetNameJ$ = Sheets("SheetConfig").Cells(LoopAP%, 1) If ThisSheetName$ = SheetNameJ$ Then GoTo LineLabelAQ Next LoopAP% Sheets(ThisSheetName$).Move After:=Workbooks(strNewFileName).Sheets(1) Workbooks(strNewFileName).Worksheets(ThisSheetName $).Activate For intSheetNum% = 1 To 3 strSheetNum$ = CStr(intSheetNum%) SheetNameK$ = "Sheet" & strSheetNum$ On Error Resume Next Set TestSheet = Worksheets(SheetNameK$) If Not TestSheet Is Nothing Then Sheets(SheetNameK$).Delete End If On Error GoTo 0 Next intSheetNum% MasterWorkbook.Activate LineLabelAQ: Next sh Workbooks(strNewFileName).Save MasterWorkbook.Activate End Sub "Kevin" wrote: My VBA for Excel code (in workbook WB1) generates some data, writes it to a worksheet (WS1), creates a new workbook (WB2), moves the worksheet (WS1) to WB2 and then activates WB1. But the taskbar appears to indicate that WB2 is active when WB1 is actually the active workbook. I can't see that any problem except for this appearance. Any thoughts? What would I do to make it appear that WB1 is active? I've uploaded a screen print. http://www.kevinjperez.com-a.googlep...m/ExcelOut.JPG Thanks. Kevin |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Activate WorkBook | Excel Programming | |||
Workbook.Activate / Window.Activate problem | Excel Programming | |||
Activate workbook | Excel Programming | |||
Activate Workbook | Excel Discussion (Misc queries) | |||
Workbook.activate | Excel Discussion (Misc queries) |