Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Brisbane, Queensland, Australia
    Posts
    330
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Writing to an Excel Worksheet (Acc 97 sr2 on 95b)

    I have managed to cobble together the following code that successfully opens a worksheet in excel.

    What I need is the extra bit of coding to be able to write a value into a specific cell on the sheet.

    All donations gratefully received.

    <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23>

    here is the code:

    Private Sub txtQPrice_Enter()
    Dim strTestFile As String

    strTestFile = Nz(Dir("C:Program FilesMicrosoft OfficeTemplatesQuotesQuote.xlt"))
    If strTestFile = "" Then Exit Sub

    If Form.DataEntry = True Then

    Dim objBooks As Object
    Dim objExcel As Object

    On Error Resume Next
    Set objExcel = GetObject(, "Excel.Application")
    If Err.Number = 429 Then
    Excelis not running; creating a Excelobject
    Set objExcel = CreateObject("Excel.Application")
    Err.Clear
    End If

    Set objBooks = objExcel.workbooks
    objBooks.Add "C:Program FilesMicrosoft OfficeTemplatesQuotesQuote.xlt"

    objExcel.Application.Visible = True
    objExcel.Parent.Windows(1).Visible = True

    Set objExcel = Nothing
    End If

    End Sub
    "Heading for the deep end"

  2. #2
    Lounger
    Join Date
    Jan 2001
    Location
    Tallinn, Harjumaa, Estonia
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Writing to an Excel Worksheet (Acc 97 sr2 on 95b)

    Hi Allan,

    For example you can write:

    objexcel.worksheets("sheet1").Range("a1")="Hello world!"

    Anu

  3. #3
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Brisbane, Queensland, Australia
    Posts
    330
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Re: Writing to an Excel Worksheet (Acc 97 sr2 on 95b)

    Thankyou so much!
    "Heading for the deep end"

Posting Permissions

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