Results 1 to 3 of 3

Thread: [RESOLVED] Load workbook invisibly

  1. #1

    Thread Starter
    Lively Member Daniel McCool's Avatar
    Join Date
    Oct 2002
    Posts
    127

    [RESOLVED] Load workbook invisibly

    How can I load a workbook without the user seing it? Also, how could I load a spreedsheet in this manner as well?

    For now, the main workbook does this to access the data information from the second workbook....

    1. Open data workbook
    2. Copy data spreedsheet
    3. Hide data spreedsheet
    4. Close data workbook

    ....works, but when the main workbook opens you can also see the second workbook open and all that mess while it's working. I'd like the user to open the main workbook and have the needed spreedsheet added without the visual display.
    Last edited by Daniel McCool; Apr 19th, 2004 at 12:12 AM.
    "Some love is fire, some love is rust. But the finest, cleanest love is lust." - James Bond

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    I don't think you can do it hidden from within the Excel app. I do
    know that you can do it from vb. Maybe have a custom button to
    execute your vb which will load the wb invisibily.
    Add a reference to "Microsoft Excel xx.x Object library"
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.     Dim oXL As Excel.Application
    5.     Dim oXLWB As Excel.Workbook
    6.     Set oXL = New Excel.Application
    7.     Set oXLWB = Workbooks.Add("D:\My Documents\Book2.xls")
    8.     oXL.Visible = False
    9.     MsgBox "Book2 loaded hidden!", vbOKOnly + vbInformation
    10. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    Lively Member TheFIDDLER's Avatar
    Join Date
    May 2002
    Location
    here and there and far away
    Posts
    126
    I think this will go a long way with what you are doing:

    application.screenupdating = false

    Provided, you are back in your original workbook at the end of your code, the user will never know the focus temporarily moved to a second workbook. Also will clear up that "mess" of stuff moving around that you refered to. Will also speed up your code.

    This is a code bit that you don't have to reset to true, it is automatically reset with the end of your subroutine.
    -----
    #VBA, VB 6 Professional Edition, Office XP Developper. Excel 97, Excel 2000, Excel XP

    I miss my VIC 20.
    Never should have upgraded to my commodore 64. ...

Posting Permissions

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



Click Here to Expand Forum to Full Width