Results 1 to 8 of 8

Thread: How do I display an Excel sheet?

  1. #1

    Thread Starter
    Hyperactive Member Datacide's Avatar
    Join Date
    Jun 2005
    Posts
    309

    How do I display an Excel sheet?

    Ok, I've scoured the forums and can't find an (easy ) answer to this. Someones got to walk me through now.

    I want my users to select an excel file and then have it load the worksheet (display it) into a table. I don't care if the table is directly editable or if it launches Excel to edit it, but I need to be able reference the cells in the table.

    Thanks.
    Last edited by Datacide; Feb 10th, 2006 at 01:16 PM.
    PHP in your FACE!

  2. #2
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Excel Question

    Quote Originally Posted by Datacide
    I want my users to select an excel file and then have it load the worksheet (display it) into a table.
    Into what type of a table? Can you give some more info?
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Excel Question

    Do you mean like a VB6 FlexGrid thats related to your selected Excel file?
    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

  4. #4

    Thread Starter
    Hyperactive Member Datacide's Avatar
    Join Date
    Jun 2005
    Posts
    309

    Re: Excel Question

    Ya either a FlexGrid thingy or an Excel OLE, or whatever would be best.
    PHP in your FACE!

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Excel Question

    well here's one way... add a reference to "Microsoft Excel X.X Object library", and use code like this:

    VB Code:
    1. '**  Declarations section
    2. Dim oXLApp as Excel.Application         'Declare the object variables
    3. Dim oXLBook as Excel.Workbook
    4. Dim oXLSheet as Excel.Worksheet
    5.  
    6. '** To open the file:
    7.   Set oXLApp = New Excel.Application    'Create a new instance of Excel
    8.   Set oXLBook = oXLApp.Workbooks.Open("C:\folder\file.xls")    'Open your workbook
    9.   Set oXLSheet = oXLBook.Worksheets(1)  'Work with the first worksheet
    10.   oXLApp.Visible = True
    11.  
    12. '** To work with the data:
    13.   With oXLSheet           'Find the row to write to
    14.     MsgBox .Cells(2, 1)   '(A2)
    15.     .Cells(1, 2) = Text2.Text   '(B1)
    16.   End With
    17.  
    18. '** To save the file:
    19.   Set oXLSheet = Nothing             'disconnect from the Worksheet
    20.   oXLBook.Close SaveChanges:= True   'Save (and disconnect from) the Workbook
    21.   Set oXLBook = Nothing
    22.   oXLApp.Quit                        'Close (and disconnect from) Excel
    23.   Set oXLApp = Nothing

  6. #6

    Thread Starter
    Hyperactive Member Datacide's Avatar
    Join Date
    Jun 2005
    Posts
    309

    Re: Excel Question

    But will that display the spread sheet? That's what I reall need.
    PHP in your FACE!

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Excel Question

    If you need to reference the cells in the table are you refering to the VB6 Grid side or Excels Cells? If Excel then your better off using the Excel Object Model in VB6. If you use the OLDE Control then you cant reference the Cells in VB6 without re-opening the file using the EOM. so not much point. See, better just using EOM to load your Grid.
    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

  8. #8

    Thread Starter
    Hyperactive Member Datacide's Avatar
    Join Date
    Jun 2005
    Posts
    309

    How do I display an Excel sheet?

    Ok, if I place the Microsoft Excel Workheet control thingy on my form, who do I change which file it displays and how would I get the data from the cells?
    PHP in your FACE!

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