Results 1 to 2 of 2

Thread: passing datas to excel from other forms

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2004
    Posts
    908

    passing datas to excel from other forms

    i have try out the sources code....however the data can only be copied from the cmdadd`s form...ie..the input from the form itself.....when i wanted to copy the data key in by the user from the previous forms...i couldnt succeed... for eg.: the addbutton was on form4 and i wanted this add button to perform not only transfer of data from form4, but i also wanted to pass the input from the previous forms ie form1,2,3 to excel .The result when i use the code below is that cell(2,1) =nothing.Why? How to pass the datas?Thanks!

    Dim Opentheform3 As New frmPR3


    Dim appXL As Excel.Application
    appXL = CreateObject("Excel.Application")

    With appXL
    .Workbooks.Open(FileName:="E:\VBN\PrDataBase.xls")
    .ActiveSheet.Cells(2, 1).Value =Opentheform3.txtLogin.Text
    .ActiveWorkbook.Save()
    .quit()
    End With

    appXL = Nothing

  2. #2
    Hyperactive Member Granty's Avatar
    Join Date
    Mar 2001
    Location
    London
    Posts
    439
    If you break on the line

    .ActiveSheet.Cells(2, 1).Value =Opentheform3.txtLogin.Text

    And hover over 'Opentheform3.txtLogin.Text' what value does it show?

    Also, try avoid using ActiveSheet and ActiveWorkBook, they're hard to keep track of.

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