Importing .csv Files Into Excel

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • smugcool
    New Member
    • Apr 2007
    • 81

    Importing .csv Files Into Excel

    hi all,

    kindly suggest me how to import .csv files into excel by using VB 6.0 SOFTWARE.Kindly help me asap.

    Regards
    Anup
  • smugcool
    New Member
    • Apr 2007
    • 81

    #2
    Originally posted by smugcool
    hi all,

    kindly suggest me how to import .csv files into excel by using VB 6.0 SOFTWARE.Kindly help me asap.

    Regards
    Anup
    Hi all,

    Plzzzzzzzzzzzzz z help its very important and urgent..I tried the same by runing a macro and it had worked....But i cant figure out the same in vb6.0

    Comment

    • SammyB
      Recognized Expert Contributor
      • Mar 2007
      • 807

      #3
      Originally posted by smugcool
      hi all,

      kindly suggest me how to import .csv files into excel by using VB 6.0 SOFTWARE.Kindly help me asap.

      Regards
      Anup
      I don't have VB6 here, so this is pretty much from memory.
      First set a reference to Microsoft Excel Object Library
      Code:
      Option Explicit
      Sub BtnExcel_Click()
      	Dim xlApp As New Excel.Application
      	Dim xlBook As Excel.Workbook
      	Set xlBook = xlApp.Workbooks.Open("C:\Documents and Settings\Sam\My Documents\IncomeSurvey.csv")
      	xlApp.Visible = True
      End Sub
      HTH --Sam

      Comment

      • smugcool
        New Member
        • Apr 2007
        • 81

        #4
        Originally posted by SammyB
        I don't have VB6 here, so this is pretty much from memory.
        First set a reference to Microsoft Excel Object Library
        Code:
        Option Explicit
        Sub BtnExcel_Click()
        	Dim xlApp As New Excel.Application
        	Dim xlBook As Excel.Workbook
        	Set xlBook = xlApp.Workbooks.Open("C:\Documents and Settings\Sam\My Documents\IncomeSurvey.csv")
        	xlApp.Visible = True
        End Sub
        HTH --Sam
        Hi Sam.,

        Above thing works when i do it in excel.....But it doesnot work when i do same thing in Vb6.

        Comment

        • SammyB
          Recognized Expert Contributor
          • Mar 2007
          • 807

          #5
          Originally posted by smugcool
          Hi Sam.,

          Above thing works when i do it in excel.....But it doesnot work when i do same thing in Vb6.
          What fails? Did you add a reference to Microsoft Excel Objects?

          Comment

          • smugcool
            New Member
            • Apr 2007
            • 81

            #6
            Originally posted by SammyB
            What fails? Did you add a reference to Microsoft Excel Objects?
            ya sam its working now.....I didnot add a reference in earlier occasion....Tha nx for your support.
            But there is one more problem now.When I ran this query it gives me entire detials in a single sales...

            I want to imported these data by delimiting semilcon.So, that i can be able to see the contents in various columns.

            Plz help

            Comment

            • SammyB
              Recognized Expert Contributor
              • Mar 2007
              • 807

              #7
              I'm not sure I followed that, but if you mean that your file is semicolon deliminated instead of comma deliminated, then you just need to parse the data after opening:
              Code:
              Option Explicit
              Sub BtnExcel_Click()
              	Dim xlApp As New Excel.Application
              	Dim xlBook As Excel.Workbook
              	Set xlBook = xlApp.Workbooks.Open("C:\Documents and Settings\Sam\My Documents\IncomeSurvey.csv")
              	xlApp.Visible = True
              	xlBook.ActiveSheet.Columns(1).TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
              		TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
              		Semicolon:=True, Comma:=False, Space:=False, Other:=False
              End Sub

              Comment

              • xavierrangel
                New Member
                • Jun 2007
                • 14

                #8
                Originally posted by SammyB
                I'm not sure I followed that, but if you mean that your file is semicolon deliminated instead of comma deliminated, then you just need to parse the data after opening:
                Code:
                Option Explicit
                Sub BtnExcel_Click()
                	Dim xlApp As New Excel.Application
                	Dim xlBook As Excel.Workbook
                	Set xlBook = xlApp.Workbooks.Open("C:\Documents and Settings\Sam\My Documents\IncomeSurvey.csv")
                	xlApp.Visible = True
                	xlBook.ActiveSheet.Columns(1).TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
                		TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
                		Semicolon:=True, Comma:=False, Space:=False, Other:=False
                End Sub



                hey there! Could you please help me out... I'm trying to open a database of access to an excel document through visual basic 6.0 any ideas? thanks a lot

                Comment

                • atharva
                  New Member
                  • Jun 2007
                  • 1

                  #9
                  Hi All,

                  I want to import A tsv file to a existing excel sheet instead of a new sheet. Kindly Help.

                  Thanks

                  Comment

                  Working...