|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
I know there are many posts with similar topics and I have tried to use them with no success. So, please give me a hand. I am trying to open .csv files in excel using VB 6.0. I have my project set up so that the .csv file name is shown in a textbox and has the name of txtCsvName. For example, the .csv file name might be GRPROD_20030901184500.csv. That shows up in my textbox after the user has made some selections. I have a command button that, when clicked, I want to open Excel with the .csv file in it. My Excel resides in C:\Program Files\Microsoft Office\Office\EXCEL.EXE. All of my .csv files reside in D:\GBFiles. Someone please show me the light. I am very new at this so I may need to be spoon fed.
Issue #2 is that when Excel does open, the columns are not the width of the text in them. How can I get the columns to format to the right width? I would really appreciate any help you guys can give me. Thanks, Bryan |
|
#2
|
|||
|
|||
|
Try something like this to open your Excel file
Code:
Dim excelapp As New Excel.Application
Dim c As New Excel.Workbook
Dim f As New Excel.Worksheet
Set c = excelapp.Workbooks.Open(App.Path & "myfile.csv")
'Do what you need to do here
c.Close
Set f = Nothing
Set c = Nothing
excelapp.Quit
Set excelapp = Nothing
|
|
#3
|
|||
|
|||
|
get column width! "x" is a column name in the excel.
Dim excelapp As New Excel.Application Dim c As New Excel.Workbook Dim f As New Excel.Worksheet Set c = excelapp.Workbooks.Open(App.Path & "myfile.csv") msgbox c.Range("x").ColumnWidth 'Do what you need to do here c.Close Set f = Nothing Set c = Nothing excelapp.Quit Set excelapp = Nothing |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Need help opening a file in Excel |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|