SunQuest
           Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old September 18th, 2003, 03:47 PM
NCXX NCXX is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 2 NCXX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 52 sec
Reputation Power: 0
Question Need help opening a file in Excel

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

Reply With Quote
  #2  
Old September 18th, 2003, 06:16 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,687 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 4 Weeks 1 Day 16 h 39 m 15 sec
Reputation Power: 688
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


Reply With Quote
  #3  
Old September 19th, 2003, 12:35 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via MSN to cleverpig
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Need help opening a file in Excel


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway