Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to start a VBA with worksheet minimize. 1

Status
Not open for further replies.

korper

Mechanical
Oct 11, 2001
15
Hi, VBA experts,
In order to beutify my prog's interface, i would like to open the Excel file(active VBA) with the worksheet in the minimized background, i.e. only the Userform or a Dialog window, from the right beginning on!
as if it was a standalone VB or VC main interface,(nothing to do with the Excel.sheets..:) Is that possible?

THX!
 
Replies continue below

Recommended for you

Sure! Using VB, there are several options available to you. This will open Excel, leaving the application visible but minimized.
Code:
Sub OpenExcelSample()
    Dim xlApp As Excel.Application
    Dim wb As Workbook, ws As Worksheet
    
    'Start Excel - Open Requested File
    Set xlApp = New Excel.Application
    
    'Minimize(xlMinimized ) or Maximize(xlMaximized)
    'the Application Window
    xlApp.WindowState = xlMinimized
    
    'Make the Application Visible
    'If False, it will not be shown on the Windows Toolbar
    '  Not Recommended because on failure, you can only
    '  access it through Explorer
    xlApp.Visible = True
    
    'Open the Excel File READ-ONLY
    Set wb = xlApp.Workbooks.Open("C:\YourFile.xls", True, True)
    
    'Open the Excel File READ-WRITE
    'Set wb = xlApp.Workbooks.Open("C:\YourFile.xls", True, False)
    
    'Select the Desired Sheet
    Set ws = wb.Sheets("Sheet1")
    
    'AND SO ON...
    
    'Clear Objects
    Set ws = Nothing
    Set wb = Nothing
    Set xlApp = Nothing
End Sub
Hope this helps... DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
Thanks!
but what i really want is within the Excel and alone with the VBA.
e.g:
Private Sub Workbook_WindowActivate(ByVal Wn As Window)
Me.Worksheets.Visible = False
'or, Excel.WindowState = xlMinimized
myprog_form.Show
End Sub

but Excel refuse to it :-(
 
No, you cannot do that because the form is contained in the application object. So, when you minimize the application, the form goes along with it. You may be able to change the size of the window so it is real small, but that's off topic. DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
If your project includes UserForm1 and on Sheet1 a CommandButton with the code calling "test":

Private Sub CommandButton1_Click()
Call test
End Sub

Sub test()
Application.WindowState = xlMinimized
AppActivate "Microsoft Excel"
UserForm1t.Show
End Sub

The UserForm1 will be shown with the Excel window minimized.
Without "AppActivate" the icon of Excel on the taskbar will blinck and only after clicking it will activate the form.

I hope this is what you want ?!?!
 
Sub test()

Application.WindowState = xlMinimized
AppActivate "Microsoft Excel"
UserForm1.Showtext

End Sub

Error "400": the userform is already there and cannot be linked.?
 
Sub test()

Application.WindowState = xlMinimized
AppActivate "Microsoft Excel"
UserForm1.Show

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor