DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 13 of 13

Thread: VB6 with Excel

  1. #1
    Join Date
    Nov 2004
    Posts
    293

    VB6 with Excel

    I have a VB6 program that puts data into an Excel workbook, this is working good except now we are switching from Excel 2003 to 2010, and I am having trouble. I belive the problem is in closing the 2003 workbook with the 2010 excel. I don't want to convert the 2003 workbook to 2010 yet because not everone has changed to Excel 2010. is there a way that I can force Excel 2010 to save the Excel 2003 workbook as a 2003 workbook?

    I think the extentions are differnet between the 2003 and 2010 Excels.

  2. #2
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,252
    Use SaveAs for the workbook. It has a file format option.
    ActiveWorkbook.SaveAs fileFormat:= xlExcel7

  3. #3
    Join Date
    Oct 2011
    Location
    USA
    Posts
    1
    Yes,
    Totally agree with that use Save As Option from File Menu for saving workbook. with that you can save your workbook with different extension.

  4. #4
    Join Date
    Nov 2004
    Posts
    293
    I take it the xlExcel7 means save as Excel 2010 ?? With or without macros??

    In my VB6 program I open an existing Excel 2003, are you saying that if I use save as xlExcel7 it would than save my file as Excel 2003??

    Thanks

  5. #5
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,649
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  6. #6
    Join Date
    Nov 2004
    Posts
    293
    Hack

    Thanks for the direction, however its a little over my head so maybe a little more help. I see the

    VB
    Copy
    'Usage
    Dim xlFileFormat1 As XlFileFormat = XlFileFormat.xlAddIn


    but don't understand what its doing or how to use it. is it meaning to use this xlFileFormat1 as the save as file type??

    Also under members it has xLExcel7 with a description of Excel 95, Hmmm ??

  7. #7
    Join Date
    Nov 2004
    Posts
    293
    I perfer not to use the "Save as" but would perfer to use only the "Save". That is because the "Save as" will ask my users if they want to overwrite the existing one where "Save" dose not. One less thing for users to get confused about.

  8. #8
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,252
    You can still use the Workbook.Close method with the save changes option, just set the format ahead of time.

    ActiveWorkbook.FileFormat = xlExcel8

    'xlExcel7 is 2002 format so xlExcel8 should be 2003 format

  9. #9
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,252
    Quote Originally Posted by AM003295 View Post
    I take it the xlExcel7 means save as Excel 2010 ?? With or without macros??

    In my VB6 program I open an existing Excel 2003, are you saying that if I use save as xlExcel7 it would than save my file as Excel 2003??

    Thanks
    No, xlWorkbookDefault is always the current version, so if you have 2007 then that is the version is would save it as. But if you use xlExcel8 then it will use Excel8 format which I believe is version 2003. I myself only have version 2002 which includes an xlExcel7 but does not include an xlExcel8. I searched the web for the 2007 docuemntation and found that it has an xlExcel8, but no xlExcel9, so I am guessing that xlExcel8 is 2003 format.

  10. #10
    Join Date
    Nov 2004
    Posts
    293
    I'll give this a try,

    thanks for the help.

  11. #11
    Join Date
    Nov 2004
    Posts
    293
    I put the following line of code in my program

    ActiveWorkbook.FileFormat = xlExcel8

    and its coming up with the .FileFormat is a read only property.
    if I read the ActiveWorkbook.FileFormat (after opening an Excel 2003 file) into a variable I get "43"

    Hmmmm looks like I can not set the file type using that property.

  12. #12
    Join Date
    Nov 2004
    Posts
    293
    OK, here is what I think is going on. If I have a VB6 program running on a computer with Office 2010, and the VB6 program opens a 2003 Excel program, the VB program can not "save" (not save as) that workbook without getting an error. However if I manual open that same 2003 Excel workbook in 2010 Excel, then manual save it as a 2003 Excel workbook, from then on my VB6 program can open and "save" that 2003 Excel workbook without the error.

    Hopes this helps someone in the future.

  13. #13
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,649
    I wonder if the same thing would happen with VB.NET - theoretically, it shouldn't, but one never knows.

    Thanks for posting your solution.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Similar Threads

  1. Replies: 4
    Last Post: 06-23-2010, 02:52 PM
  2. Importing Excel Data
    By rrjii2000 in forum .NET
    Replies: 10
    Last Post: 03-26-2010, 01:34 PM
  3. VB6 can't open excel sheet after it's created
    By MFB1 in forum VB Classic
    Replies: 8
    Last Post: 06-24-2008, 02:54 PM
  4. open & close EXCEL with VB6
    By Garner in forum VB Classic
    Replies: 18
    Last Post: 05-13-2006, 11:59 PM
  5. Using VB6 to write to an Excel file.
    By AM003295 in forum VB Classic
    Replies: 7
    Last Post: 04-18-2005, 04:28 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links