Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default open and activate workbook?

In some minor testing, this only caused a problem for me if the worksheet window
was not maximized.

If I maximized the worksheet window, then opened a workbook that had its windows
minimized, it was opened maximized (did that make sense???).

So I could add a line before showing the dialog that maximizes the window:

ActiveWindow.WindowState = xlMaximized

Another option is to just open it and then maximize it. I like displaying the
getopenfilename dialog and controlling what happens later.

Option Explicit
Sub testme01()

Dim wkbk As Workbook
Dim myFileName As Variant

myFileName = Application.GetOpenFilename("Excel File, *.xls")

If myFileName = False Then
Exit Sub 'user hit cancel
End If

Set wkbk = Workbooks.Open(Filename:=myFileName)

wkbk.Windows(1).WindowState = xlMaximized

End Sub



schpank wrote:

I am using a dialog box to have the user select an open file, but if the file opened happens to be saved as minimized, it does not activate. I am just trying to copy some data from the opened file, then go back to the file with the macro to paste etc. Seems like there should be a way to reference the newly opened file and activate it? Or open it and activate it as one step? any help appreciated:
Application.Dialogs(xlDialogOpen).Show arg1:=""
Range("$A$1:$A$6").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
ThisWorkbook.Activate


--

Dave Peterson

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
can't seem to activate an open workbook dantee Excel Discussion (Misc queries) 1 July 11th 08 02:48 AM
How to auto activate macro when file open ? bonzio Excel Worksheet Functions 1 December 16th 05 02:45 PM
Workbook.activate Jeff Excel Discussion (Misc queries) 1 December 13th 04 10:22 PM
Excel VBA - Activate Open Workbooks to format exceller Excel Programming 2 June 10th 04 12:14 PM
Activate Workbook Molly Johnson Excel Programming 1 February 10th 04 05:09 PM


All times are GMT +1. The time now is 02:16 PM.

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"