Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: Excel Objects


Message #1 by Richard Santoro <RSantoro@h...> on Wed, 6 Dec 2000 15:22:56 -0700
Thanks for the help.  Richard.

-----Original Message-----
From: Polsky, Eva [mailto:EPolsky@s...]
Sent: Thursday, December 07, 2000 11:19 AM
To: professional vb
Subject: [pro_vb] RE: Excel Objects


Richard,
I have an application where I'm working with the file in Excel and
converting it to the text file format(with some other functionality). I'm
creating a temporary file in CSV format, work with it and then remove it.
 The snippet of the code as follows:

 With lExcelApp
         
          .Workbooks.Open FileName:=MyForm.dirDirectory.Path & "\" & lInput
          lTempFile = MyForm.dirDirectory.Path & "\" & lTemp & ".csv"
          .ActiveWorkbook.SaveAs FileName:=lTempFile, _
                                FileFormat:=xlCSV, _
                                ReadOnlyRecommended:=False, _
                                CreateBackup:=False, _
                                AccessMode:=xlExclusive
                              
       
          .ActiveWorkbook.Close SaveChanges:=False
          
  End With

Work with the tempfile, create the new one and then  "Kill lTempFile"

I hope it will help you out!

> 	Eva 
> 	mailto:EPolsky@s...
> 


-----Original Message-----
From: Richard Santoro [mailto:RSantoro@h...]
Sent: Wednesday, December 06, 2000 5:23 PM
To: professional vb
Subject: [pro_vb] Excel Objects


I have an app where I open an Excel workbook and copy data from a grid. The
data is fixed width. 
 I would like the user to be able to insert break lines. How do I invoke the
Text Import Wizard prior to displaying the data in Excel? 
Any help would be appreciated.  Thanks in advance. 

Richard 


        Set GXlApp = CreateObject("Excel.Application")
        Set XlBook = GXlApp.Workbooks.Add
        Set XlSheet = XlBook.Worksheets(1)
        For i = 1 To DataGrid.ColumnSet.Count
            GXlApp.Cells(1, i) = DataGrid.ColumnSet(i - 1).Heading
        Next
        GExcelCount = DataGrid.RowSet.Count
        frmExcelSp.pvLoadExcel.Limit = DataGrid.RowSet.Count
        For j = 1 To DataGrid.RowSet.Count
            For i = 1 To DataGrid.ColumnSet.Count
                If i = 2 Then
                    item = Format(DataGrid.CellSet(j - 1, 1).Value,
"hh:mm:ss AMPM")
                Else
                    item = DataGrid.CellSet(j - 1, i - 1).Value
                End If
                GXlApp.Cells(j + 1, i).Value = item
            Next
            frmExcelSp.pvLoadExcel.Value = j
        Next
        GXlApp.EnableEvents = True
        Set XlRange = XlSheet.UsedRange
        XlRange.Columns.AutoFit
        GXlApp.Visible = True


  Return to Index