Consulting

Results 1 to 12 of 12

Thread: make the Application active

  1. #1
    VBAX Regular
    Joined
    Aug 2007
    Posts
    16
    Location

    make the Application active

    Hi guys,

    My Problem is not so big but still I want to solve it.I have designed/programmed an application in Excel.Now when I click the .xls File I want only the application to be active not the Worksheets.I have achieved that by hiding the woksheets with [VBA]Application.Workbooks.Application.Visible = False
    [/VBA] it works fine but when I close the application and start the .xls File again then appears a message that the .xls is already opened.As far as I understand the problem , when I click the close-button it does NOT close the Worksheets.If anyone can help me it would be great.Thanks in advance!

    Cheers
    Valeri

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    How do you click a close button when the applictaion is not visible?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Aug 2007
    Posts
    16
    Location
    I meant actually:
    [VBA]
    Application.Workbooks.Parent.Visible = False
    [/VBA]

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    That is still the application is it not? So my question still stands.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Regular
    Joined
    Aug 2007
    Posts
    16
    Location
    no its not the application its the .xls File.Try it!

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I did. The parent of Workbooks is the application.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    That is what your first post says as well, Application.Workbooks.Application.Visible = False is still the application. Do you have multiple instances running concurrently? Perhaps a little more detail on your part as to what you are doing here step-by-step. Screenshots and code posts help a lot.

  8. #8
    VBAX Newbie
    Joined
    Nov 2007
    Posts
    1
    Location
    Hi Metev,

    Try this

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Workbooks.Application.Visible = True
    For Each wb In Application.Workbooks
    wb.Save
    Next wb
    Application.Quit
    End Sub

  9. #9
    VBAX Regular
    Joined
    Aug 2007
    Posts
    16
    Location
    please dont consider the first post!
    I have an applicaton that I have been designing for the past 1 year.My problem is when I open the .xls file both the worksheets and UserForm appear.Now I want only to activate the Userform just to make sure that nobody will change my worksheets.So what I did is :

    Wrote this piece of code.And It did work.When I open the .xls File only the UserForm appears and the Sheets are invisible.When I close the UF it doesnt automaticaly close the whole .xls File.I was wondering is there any way when I close the UF also to close the whole File.

    Thats all!

    there is the screenshot!When I dont write ..[vba]Application.Workbooks.Parent.Visible = False[/vba]
    the Sheets are also visible![IMG]file:///C:/Dokumente%20und%20Einstellungen/ivo/Desktop/withcode.bmp[/IMG]

  10. #10
    VBAX Regular
    Joined
    Aug 2007
    Posts
    16
    Location
    actually can you see the screenshot?

  11. #11
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Check out the userforms queryclose event.

  12. #12
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    That is because you have hidden the application, and when you close the userform, you still have an invisible application open.

    You need to make the application visible inthe form QueryClose routine, and also close any applicable workbooks.

    BTW, did YOU try it?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •