visual basic express read/write to excel question
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 14 of 14

Thread: visual basic express read/write to excel question

  1. #1
    Join Date
    Jan 2013
    Location
    paso robles ca
    Posts
    5

    visual basic express read/write to excel question

    i have downloaded vbe 2010 and thats where im pretty much stuck . i do logic programing this type of code is killing me . is their an easier way . this is what i got , an excel spreadsheet runs my project .all i need is access to cell B1 to input a text string , and access to cell E1 so i can see what my value is , thats it , two little windows on a vbe screen . i just dont like the look of the spreadsheet when i convert to an exe. so i figured vbe screen would cover it up . am i wrong as hell or what
    thanks

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,090

    Re: visual basic express read/write to excel question

    [ Moved ]

  3. #3
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,981

    Re: visual basic express read/write to excel question

    Export to TEXT, and then read the file. Problem solved!
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  4. #4
    Join Date
    Jan 2013
    Location
    paso robles ca
    Posts
    5

    Re: visual basic express read/write to excel question

    this is a voice control program . i just need it to look neat . i talk into cell B1 , my spreadsheet runs a calc. then my value seen in cell E1 . ive looked all over the web and cant find code that doesnt include a button . i need full time access to cell B1 and a full time view of cell E1 because the software will run 24-7 .is their another option to convert my spreadsheet to a stand alone program without looking like a spreadsheet ?

  5. #5
    DataMiser is online now Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,823

    Re: visual basic express read/write to excel question

    Does it really need to be a spreadsheet, does it even need to use Excel?
    Always use [code][/code] tags when posting code.

  6. #6
    Join Date
    Jan 2013
    Location
    paso robles ca
    Posts
    5

    Re: visual basic express read/write to excel question

    eventually it will be all code , a stand alone program . i have perfected voice control that can apply to anything . i am meeting with prosthetic companies next week hopefully to apply it to a bionic hand . ill be making videos of some applications this weekend . do you have other suggestions for hiding the sheet for now .

  7. #7
    DataMiser is online now Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,823

    Re: visual basic express read/write to excel question

    Not really, I don't know enough about what you are doing and Excel would be so far down my list of options that it would not be considered. Typically I would use a database or a flat file depending on what I need and then write code to handle any calculations and display needed but then I have no idea what this spreadsheet looks like nor what data is in it or what kinds of calculations it may be doing.

    If you don't want to see the sheet but need the data from it then I would consider exporting the data to a TAB delimited or CSV file and then use the data in the program and eliminate Excel from the equation.
    Always use [code][/code] tags when posting code.

  8. #8
    Join Date
    Jan 2013
    Location
    paso robles ca
    Posts
    5

    Re: visual basic express read/write to excel question

    I'm guessin david was breast fed by daddy. Is there a way I can get a private message to datamiser ?

  9. #9
    DataMiser is online now Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,823

    Re: visual basic express read/write to excel question

    I prefer to keep questions and answers in the forums so others may be helped. Also there are others here who may be able to add to the topic and help you in the process.
    Always use [code][/code] tags when posting code.

  10. #10
    Join Date
    Jan 2013
    Location
    paso robles ca
    Posts
    5

    Re: visual basic express read/write to excel question

    Ok can you do a visual basic app that has one text box that writes to cell B1 and a window that looks at cell E1 ?

  11. #11
    DataMiser is online now Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,823

    Re: visual basic express read/write to excel question

    I do not use Excel in my apps, I really hate working with it.
    Like I said before unless there is some specific reason to use Excel then I would not use it. I would export the data to a different format and work with the data.
    Always use [code][/code] tags when posting code.

  12. #12
    Join Date
    Aug 2009
    Location
    NW USA
    Posts
    173

    Re: visual basic express read/write to excel question

    Here are some chunks of stuff I've used before:
    Code:
            Dim oExcel, oBook, oSheet As Object
            oExcel = CreateObject("Excel.Application")
            oBook = oExcel.workbooks.add
            oSheet = oBook.worksheets(1) ' the sheets are 1 based - not zero
            oSheet.cells(1,1).value = "Hello World" ' the cells are 1 based - not zero
            msgbox(oSheet.cells(1,1).value)
            oBook.saveas("Tester")
            oBook.close()
            oExcel.quit()
            oSheet = Nothing
            oBook = Nothing
            oExcel = Nothing
    probably want to try an "open" on the workbook or worksheet object then a loop to monitor the cell in question.

  13. #13
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    51

    Re: visual basic express read/write to excel question

    It's pretty simple with the Microsoft Office Interop namespaces... http://msdn.microsoft.com/en-US/libr...=vs.80%29.aspx

    Why are you using Excel though? Just to see if you can input the data to a spreadsheet? :S The calculation part of it can be done with functions in Excel directly.

    If you don't want to do it the COM way, then you could attempt uncompressing the archive (compressed with the DEFLATE/Base64 method like most zip archives) to reveal all of the XML files that are used for the spreadsheet, and edit those.
    Last edited by AceInfinity; February 3rd, 2013 at 06:43 PM.

    Microsoft MVP .NET Programming (2012 - Present)
    ®Crestron DMC-T Certified Automation Programmer

  14. #14
    Join Date
    Jul 2011
    Posts
    6

    Re: visual basic express read/write to excel question

    Write Excel:

    Code:
    sheet.Range("B1").Text = "XYZ"
    Read Excel:

    Code:
    sheet.Range("E1").Value
    I use a VB.NET Excel component.

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center