Welcome to dbFreaks.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Create property in an Excel file?

 
   Database Help (Home) -> Visual Basic -> DAO RSS
Next:  CreateWorkspace  
Author Message
Martin2

External


Since: Oct 23, 2003
Posts: 1



(Msg. 1) Posted: Thu Oct 23, 2003 4:10 pm
Post subject: Create property in an Excel file?
Archived from groups: microsoft>public>vb>database>dao (more info?)

I'm using the following code (VB6; DAO3.6) to create an .XLS file.

--------------------------------------
Dim ExcelDB As DAO.Database
Dim td As DAO.TableDef
Dim NewField As DAO.Field
Dim NewProp As DAO.Property
Dim I


Set ExcelDB = DBEngine.Workspaces(0).OpenDatabase(App.Path &
"\Test.XLS", dbDriverNoPrompt, False, "Excel 8.0")

Set td = ExcelDB.CreateTableDef("DataLog")

Set NewField = td.CreateField("DateTime", dbDate)
td.Fields.Append NewField

Set NewField = td.CreateField("Description", dbText)
td.Fields.Append NewField

ExcelDB.TableDefs.Append td
--------------------------------------

Now, I want to assign a specific format to the "DateTime" field. From
what I've read in various places, the following statement should do it
but it generates error 3310 "Property not supported for external data
sources..."

Set NewProp = td.Fields("DateTime").CreateProperty("NumberFormat",
dbText, "m/dd/yy hh:mm:ss")

td.Properties.Append NewProp

Can someone tell me what I'm doing wrong here?

 >> Stay informed about: Create property in an Excel file? 
Back to top
Login to vote
Paul Clement

External


Since: Sep 02, 2003
Posts: 236



(Msg. 2) Posted: Fri Oct 24, 2003 11:58 am
Post subject: Re: Create property in an Excel file? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Thu, 23 Oct 2003 13:10:58 -0700, Martin <martinNO-SPAMvalley.RemoveThis@comcast.net> wrote:

¤ I'm using the following code (VB6; DAO3.6) to create an .XLS file.
¤
¤ --------------------------------------
¤ Dim ExcelDB As DAO.Database
¤ Dim td As DAO.TableDef
¤ Dim NewField As DAO.Field
¤ Dim NewProp As DAO.Property
¤ Dim I
¤
¤
¤ Set ExcelDB = DBEngine.Workspaces(0).OpenDatabase(App.Path &
¤ "\Test.XLS", dbDriverNoPrompt, False, "Excel 8.0")
¤
¤ Set td = ExcelDB.CreateTableDef("DataLog")
¤
¤ Set NewField = td.CreateField("DateTime", dbDate)
¤ td.Fields.Append NewField
¤
¤ Set NewField = td.CreateField("Description", dbText)
¤ td.Fields.Append NewField
¤
¤ ExcelDB.TableDefs.Append td
¤ --------------------------------------
¤
¤ Now, I want to assign a specific format to the "DateTime" field. From
¤ what I've read in various places, the following statement should do it
¤ but it generates error 3310 "Property not supported for external data
¤ sources..."
¤
¤ Set NewProp = td.Fields("DateTime").CreateProperty("NumberFormat",
¤ dbText, "m/dd/yy hh:mm:ss")
¤
¤ td.Properties.Append NewProp
¤
¤ Can someone tell me what I'm doing wrong here?


The creation of user defined properties using CreateProperty is only supported by Jet (Access)
database types.


Paul ~~~ pclement.RemoveThis@ameritech.net
Microsoft MVP (Visual Basic)

 >> Stay informed about: Create property in an Excel file? 
Back to top
Login to vote
Martin

External


Since: Sep 22, 2003
Posts: 30



(Msg. 3) Posted: Fri Oct 24, 2003 11:58 am
Post subject: Re: Create property in an Excel file? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Fri, 24 Oct 2003 08:58:33 -0500, Paul Clement
<UseAdddressAtEndofMessage.RemoveThis@swspectrum.com> wrote:

 >
 >The creation of user defined properties using CreateProperty is only supported by Jet (Access)
 >database types.
 >

Paul -

Thanks. I had been told that it could be done but I sure couldn't get
it to work.

Do you know if there is any way I can set the format for the DateTime
field?

In Excel itself, it's a simple matter of specifying the desired format
but I would like to do it from within my program so that when the user
eventually opens the .XLS file, the data will be properly displayed.<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Create property in an Excel file? 
Back to top
Login to vote
Paul Clement

External


Since: Sep 02, 2003
Posts: 236



(Msg. 4) Posted: Mon Oct 27, 2003 1:25 pm
Post subject: Re: Create property in an Excel file? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Fri, 24 Oct 2003 07:05:15 -0700, Martin <martinvalley RemoveThis @comcast.net> wrote:

¤ On Fri, 24 Oct 2003 08:58:33 -0500, Paul Clement
¤ <UseAdddressAtEndofMessage RemoveThis @swspectrum.com> wrote:
¤
¤ >
¤ >The creation of user defined properties using CreateProperty is only supported by Jet (Access)
¤ >database types.
¤ >
¤
¤ Paul -
¤
¤ Thanks. I had been told that it could be done but I sure couldn't get
¤ it to work.
¤
¤ Do you know if there is any way I can set the format for the DateTime
¤ field?
¤
¤ In Excel itself, it's a simple matter of specifying the desired format
¤ but I would like to do it from within my program so that when the user
¤ eventually opens the .XLS file, the data will be properly displayed.

The only method I'm aware of is to use automation with Excel. You may be able to force it using the
Format function but I haven't tried it and I don't know how you are placing data in the cells.


Paul ~~~ pclement RemoveThis @ameritech.net
Microsoft MVP (Visual Basic)
 >> Stay informed about: Create property in an Excel file? 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Problem with DAO (Import from Excel to Access)! :( - Hi, I am novice and I have problem. I need import some data with Excel file to Access. Problem introduces as follows: In Excel(first sheet) i have data: "TYTUL" - column "A" "NAZWISKO" - column "B" "IMIE&quot...

Using Jet data control to write numbers to an excel spread.. - Hi, I'm currently using the vb data controls to write numbers to excel spreadsheets using the Jet driver. Unfortunately, even though the data being sent to the spreadsheet is numbers, excel has a nasty habit of showing them as text, requiring them t...

Copy a table from one MDB file to another? - Is there a relatively simple DAO (or SQL) statement that I can execute in my VB6 program that will copy a table (structure only - no data) from one MDB file to another MDB file?

Error conneecting to Access "Cannot Start Your Application.. - I can connect to the database manually, by starting it and entering my login info, but I still get that error. Here is my code: Sub SetUpConnection() On Error GoTo ErrHandler Set adoCN = New Connection adoCN.Provider =..

Connect Data Control to Access 97 secured DB via MDW file .. - Re VB 6.0 & Access 97 I am using the MS Data Control on a form which I need to refresh each time the user enters criteria. The DB is secured via an MDW file. Could someone please provide an example, using DAO, with a solution to connect the Data..
   Database Help (Home) -> Visual Basic -> DAO All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]