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:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old September 17th, 2003, 08:26 AM
gabaug gabaug is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 6 gabaug User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Date formats when saving an excel from VB

I use Excel automation from VB to open a Worksheet and save it as text, the save method writes date with a strange behavior.

If my PC regional settings are dd/mm/yyyy and the excel cell format is dd/mm/yyyy, the resulting field goes mm/dd/yyyy. All the other 3 combinations (PC dd/mm and cell dd/mm; PC mm/dd and cell mm/dd; PC mm/dd and cell dd/mm) goes ok.

I need to run the code against all 4 combinations.

Is there any way to force a right formatting?

The code is:

Set objExcApp = GetObject("", "Excel.Application")
Set objExcWb = objExcApp.Workbooks.Open("mydata.xls")
Set objExcWs = objExcWb.Worksheets("sheet1")
objExcWs.SaveAs FileName:="mydata.txt", FileFormat:=xlText, CreateBackup:=False

Reply With Quote
  #2  
Old September 22nd, 2003, 12:42 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: 7
Send a message via MSN to cleverpig
u try the NumberFormat proper:
Worksheets("Sheet1").Range("A17").NumberFormat = "General"
Worksheets("Sheet1").Rows(1).NumberFormat = "hh:mm:ss"
Worksheets("Sheet1").Columns("C"). _
NumberFormat = "$#,##0.00_);[Red]($#,##0.00)"

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Date formats when saving an excel from VB


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 6 hosted by Hostway