×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How to start a VBA with worksheet minimize.

How to start a VBA with worksheet minimize.

How to start a VBA with worksheet minimize.

(OP)
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!

RE: How to start a VBA with worksheet minimize.

Sure! Using VB, there are several options available to you. This will open Excel, leaving the application visible but minimized.

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.

RE: How to start a VBA with worksheet minimize.

(OP)
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

RE: How to start a VBA with worksheet minimize.

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.

RE: How to start a VBA with worksheet minimize.

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 ?!?!

RE: How to start a VBA with worksheet minimize.

(OP)
Sub test()

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

End Sub

Error "400": the userform is already there and cannot be linked.?

RE: How to start a VBA with worksheet minimize.

Sub test()

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

End Sub

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources