Results 1 to 17 of 17

Thread: Using a excel sheet in a form

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2005
    Posts
    20

    Using a excel sheet in a form

    Hi.
    I want to use an excel sheet in a form and read the edited values in the sheet.
    First I inserted an "insertable object" Microsoft Excel Woksheet. However i can't access the values that the custumer puts in my sheet. I want to use something like:

    Var1=Sheet.Cells(1,1)

    It's that possible?
    Anyone have any trick?

    Thanks in advance!

  2. #2
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Re: Using a excel sheet in a form

    I'm guessing it might be easier to use a flexgrid and just read and write values back and forth from Excel.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2005
    Posts
    20

    Re: Using a excel sheet in a form

    I can't easaly edit, delete or insert rows, with flex grid...

  4. #4
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Re: Using a excel sheet in a form

    I've actually never tried this before, but I'm guessing that you would have to somehow get a reference to the Excel sheet and then use the Excel object model to interact with it. Can you post some more code or the project files?

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Aug 2005
    Posts
    20

    Re: Using a excel sheet in a form

    I don't have any code! I just put a shet in my form and now I want to find a way to get and put values and text in that sheet...

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Aug 2005
    Posts
    20

    Re: Using a excel sheet in a form

    I'm tired! I try many things without sucess!
    Any trick?

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

    Re: Using a excel sheet in a form

    What version of Excel do you have? You can access a particualr cell like you posted using the Excel Object Model or you can show a sheet on a form using the OLE control.

    to automate Excel...

    VB Code:
    1. Option Explicit
    2. 'Add a reference to ms excel xx.0 object library
    3. Private sub command1_click()
    4.     dim oapp as excel.application
    5.     dim owb as excel.workbook
    6.     set oapp = new excel.application
    7.     set owb = oapp.workbooks.open("C:\MyFile.xls")
    8.     owb.sheets("sheet1").Cells(1,1) = "Test"
    9.     msgbox owb.sheets("sheet1").Cells(1,1)
    10.     owb.save
    11.     owb.close
    12.     set owb = nothing
    13.     oapp.quit
    14.     set oapp = nothing
    15. 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

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Aug 2005
    Posts
    20

    Re: Using a excel sheet in a form

    I want to put a excel worksheet in my form.Is that possible with OLE. But I can't access it!
    How can I do it?

  9. #9
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Using a excel sheet in a form

    Put an OLE control on your form (OLE controls are found on your Toolbar) and link it to your spreadsheet.

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

    Re: Using a excel sheet in a form

    The OLE link should be either Linked or Embedded, only two choices. Once on your form, click on it to activate/Edit, etc. during run time.
    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

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Aug 2005
    Posts
    20

    Re: Using a excel sheet in a form

    And, with a embebed sheet, how can I access, for example, at the cell(1,1)?

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

    Re: Using a excel sheet in a form

    AFAIK, you would have to invoke the double left clicking to create an instance of the embedded workbook first. I really dont get the reason you would want to show the workbook on a form embedded if you need to manipulate it programmatically?
    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

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Aug 2005
    Posts
    20

    Re: Using a excel sheet in a form

    I need a table where the custumer can easaly edit, insert and remove rows. My idea is use a excel worksheet to do it.

  14. #14
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: Using a excel sheet in a form

    Warning: Thread Resurrection.

    Did this ever get resolved? I need to do this too. I need to embed an Excel-like sheet into a Form and access it programatically.

    Thanks!

    Dave
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

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

    Re: Using a excel sheet in a form

    Sup Dave. You can use an Insertable Object called the "Microsoft Office Excel Worksheet". Its very similar to OLE but much better and updated.

    Attached Images Attached Images  
    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

  16. #16
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: Using a excel sheet in a form

    Right on, bro! Any idea how similar this interface is to the regular WorkSheet Object? Any docs on the subject?

    Quote Originally Posted by RobDog888
    Sup Dave. You can use an Insertable Object called the "Microsoft Office Excel Worksheet". Its very similar to OLE but much better and updated.

    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

  17. #17
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: Using a excel sheet in a form

    So is there a way to access the Object programatically? Like can I get a Range out of it at run-time?
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

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