Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 504
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 504
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Activate WorkBook Dave Peterson Excel Programming 0 December 27th 06 09:15 PM
Workbook.Activate / Window.Activate problem Tim[_44_] Excel Programming 3 February 3rd 06 11:38 PM
Activate workbook TimT Excel Programming 5 November 29th 05 08:41 PM
Activate Workbook Dolphinv4 Excel Discussion (Misc queries) 2 October 22nd 05 01:45 PM
Workbook.activate Jeff Excel Discussion (Misc queries) 1 December 13th 04 10:22 PM


All times are GMT +1. The time now is 06:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"