Results 1 to 6 of 6

Thread: VB to Excel

  1. #1

    Thread Starter
    Hyperactive Member parkes's Avatar
    Join Date
    Jan 1999
    Location
    Unitied Kingdom
    Posts
    303

    Post

    I'm using VB6 and Excel

    I've got an Excel spreadsheet already created and I want to send information to certain cells.
    Does anyone have an example on how to do this.

    ------------------
    Thanks in advance for any help provided.

  2. #2
    New Member
    Join Date
    Jan 2000
    Location
    Blackpool
    Posts
    14

    Post

    I'm stuck on this to cannot find anything on the web....is it possible??

  3. #3
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    It is possible. I had the same problem, the help files in VB and Excel didn't help until I looked at both and cross-referenced them and guessed a bit. I'm in the middle of something but when I get a chance I will see if I can my code doing it.
    Basically, you need to make an Excel object, use it to open the file and then just do things with the properties etc. It may take me a bit, gotta finish some stuff first.


    Quick example doing it in Access's VBA, opening a Word Document.

    Dim WordDoc As Object
    Set WordDoc = CreateObject("word.application")
    WordDoc.Application.Visible = True
    WordDoc.Application.Documents.Open strFileName
    WordDoc.Application.windowstate = 1

    Basically it's the same but using and Excel object and OpenObject or similar. Hope this gets you started in the right direction. Let me know if you need more or if this helped enough.

    [email protected]

    [This message has been edited by netSurfer (edited 01-13-2000).]

  4. #4

    Thread Starter
    Hyperactive Member parkes's Avatar
    Join Date
    Jan 1999
    Location
    Unitied Kingdom
    Posts
    303

    Post

    Thanks people, I've found the answer, so if you want I'll post it for you. Or you can email me and I'll send it

    ------------------
    Thanks in advance for any help provided.

  5. #5
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    Sure, could you post it.

  6. #6

    Thread Starter
    Hyperactive Member parkes's Avatar
    Join Date
    Jan 1999
    Location
    Unitied Kingdom
    Posts
    303

    Post

    Right here is the basic information:

    Private tmpWorkbook As Excel.Workbook
    Private tmpWorkSheet As Excel.Worksheet

    Private Sub cmdExport_Click()

    Dim fname As String
    fname = "c:\my documents\test.xls"
    Set tmpWorkbook = GetObject(fname)
    tmpWorkbook.Sheets("Sheet 1").Select
    Set tmpWorkSheet = tmpWorkbook.ActiveSheet
    With tmpWorkSheet
    .Cells(7,3)="Testing"
    End With

    End Sub

    Hope this helps.


    ------------------
    Thanks in advance for any help provided.

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