<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ADO Connection Create File Excel in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/ado-connection-create-file-excel/m-p/1675930#M33580</link>
    <description>Thx for the link.&lt;BR /&gt;
Ithink i have to use application excel for create the file and after close file and modifing with ado.&lt;BR /&gt;
&lt;BR /&gt;
it is much easy for use a bas with ado.&lt;BR /&gt;
and i have a little prob for close excel.exe. &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;</description>
    <pubDate>Thu, 15 Jun 2006 15:55:07 GMT</pubDate>
    <dc:creator>Aubelec</dc:creator>
    <dc:date>2006-06-15T15:55:07Z</dc:date>
    <item>
      <title>ADO Connection Create File Excel</title>
      <link>https://forums.autodesk.com/t5/vba-forum/ado-connection-create-file-excel/m-p/1675928#M33578</link>
      <description>Hello.&lt;BR /&gt;
How créate a ADO connection for create un file .XLS ?&lt;BR /&gt;
I know how read a existing file XLS. &lt;BR /&gt;
SQL command : SELEC * ...  but if i use CREATE TABLE...  &lt;BR /&gt;
the vba say : the file open only in read.&lt;BR /&gt;
&lt;BR /&gt;
dim strfile as string&lt;BR /&gt;
Dim cnn As New ADODB.Connection&lt;BR /&gt;
dim rs as new ADODB.Recordset&lt;BR /&gt;
strfile=c:\mynewfile.xls&lt;BR /&gt;
cnn.ConnectionString = "Driver={Microsoft Excel Driver (*.xls)};DBQ=" &amp;amp; strfile"&lt;BR /&gt;
cnn.open&lt;BR /&gt;
rs.open "Create table ..."&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
How create a file .XLS without the excel application ?</description>
      <pubDate>Thu, 15 Jun 2006 10:02:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/ado-connection-create-file-excel/m-p/1675928#M33578</guid>
      <dc:creator>Aubelec</dc:creator>
      <dc:date>2006-06-15T10:02:34Z</dc:date>
    </item>
    <item>
      <title>Re: ADO Connection Create File Excel</title>
      <link>https://forums.autodesk.com/t5/vba-forum/ado-connection-create-file-excel/m-p/1675929#M33579</link>
      <description>I doubt that you can create an Excel file without the Excel application.  I&lt;BR /&gt;
think that your code would not create a file if it worked; it would create&lt;BR /&gt;
a named range.&lt;BR /&gt;
&lt;BR /&gt;
Excel is not really a database, and there are restrictions on what ADO can&lt;BR /&gt;
do with an Excel file. See&lt;BR /&gt;
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q257819 .&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
jrf &lt;BR /&gt;
Autodesk Discussion Group Facilitator &lt;BR /&gt;
Please do not email questions unless you wish to hire my services&lt;BR /&gt;
&lt;BR /&gt;
On Thu, 15 Jun 2006 10:02:34 +0000, Aubelec wrote:&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt; Hello.&lt;BR /&gt;
&amp;gt; How créate a ADO connection for create un file .XLS ?&lt;BR /&gt;
&amp;gt; I know how read a existing file XLS. &lt;BR /&gt;
&amp;gt; SQL command : SELEC * ...  but if i use CREATE TABLE...  &lt;BR /&gt;
&amp;gt; the vba say : the file open only in read.&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; dim strfile as string&lt;BR /&gt;
&amp;gt; Dim cnn As New ADODB.Connection&lt;BR /&gt;
&amp;gt; dim rs as new ADODB.Recordset&lt;BR /&gt;
&amp;gt; strfile=c:\mynewfile.xls&lt;BR /&gt;
&amp;gt; cnn.ConnectionString = "Driver={Microsoft Excel Driver (*.xls)};DBQ=" &amp;amp;&lt;BR /&gt;
strfile"&lt;BR /&gt;
&amp;gt; cnn.open&lt;BR /&gt;
&amp;gt; rs.open "Create table ..."&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; How create a file .XLS without the excel application ?</description>
      <pubDate>Thu, 15 Jun 2006 11:48:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/ado-connection-create-file-excel/m-p/1675929#M33579</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-15T11:48:56Z</dc:date>
    </item>
    <item>
      <title>Re: ADO Connection Create File Excel</title>
      <link>https://forums.autodesk.com/t5/vba-forum/ado-connection-create-file-excel/m-p/1675930#M33580</link>
      <description>Thx for the link.&lt;BR /&gt;
Ithink i have to use application excel for create the file and after close file and modifing with ado.&lt;BR /&gt;
&lt;BR /&gt;
it is much easy for use a bas with ado.&lt;BR /&gt;
and i have a little prob for close excel.exe. &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;</description>
      <pubDate>Thu, 15 Jun 2006 15:55:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/ado-connection-create-file-excel/m-p/1675930#M33580</guid>
      <dc:creator>Aubelec</dc:creator>
      <dc:date>2006-06-15T15:55:07Z</dc:date>
    </item>
    <item>
      <title>Re: ADO Connection Create File Excel</title>
      <link>https://forums.autodesk.com/t5/vba-forum/ado-connection-create-file-excel/m-p/1675931#M33581</link>
      <description>Sounds more like you should be using a database application to create a &lt;BR /&gt;
database instead.&lt;BR /&gt;
&lt;BR /&gt;
Joe&lt;BR /&gt;
--&lt;BR /&gt;
&lt;BR /&gt;
&lt;AUBELEC&gt; wrote in message news:5207650@discussion.autodesk.com...&lt;BR /&gt;
Thx for the link.&lt;BR /&gt;
Ithink i have to use application excel for create the file and after close &lt;BR /&gt;
file and modifing with ado.&lt;BR /&gt;
&lt;BR /&gt;
it is much easy for use a bas with ado.&lt;BR /&gt;
and i have a little prob for close excel.exe. &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;/AUBELEC&gt;</description>
      <pubDate>Thu, 15 Jun 2006 16:34:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/ado-connection-create-file-excel/m-p/1675931#M33581</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-15T16:34:18Z</dc:date>
    </item>
    <item>
      <title>Re: ADO Connection Create File Excel</title>
      <link>https://forums.autodesk.com/t5/vba-forum/ado-connection-create-file-excel/m-p/1675932#M33582</link>
      <description>You need ADOX to do it.&lt;BR /&gt;
&lt;BR /&gt;
This is how you would create the excel file&lt;BR /&gt;
&lt;BR /&gt;
Dim cat As ADOX.Catalog&lt;BR /&gt;
Dim tbl As ADOX.Table&lt;BR /&gt;
Dim col As ADOX.Column&lt;BR /&gt;
&lt;BR /&gt;
Set cat = New ADOX.Catalog&lt;BR /&gt;
&lt;BR /&gt;
cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" &amp;amp; "Data Source=" &lt;BR /&gt;
&amp;amp; myfile &amp;amp; ";Extended Properties=Excel 8.0"&lt;BR /&gt;
Set tbl = New ADOX.Table&lt;BR /&gt;
tbl.Name = "Sample"&lt;BR /&gt;
&lt;BR /&gt;
'do this for each column in the table&lt;BR /&gt;
Set col = New ADOX.Column&lt;BR /&gt;
With col&lt;BR /&gt;
    .Name = "myTipe"&lt;BR /&gt;
    .Type = adVarWChar&lt;BR /&gt;
    .DefinedSize = 80&lt;BR /&gt;
End With&lt;BR /&gt;
tbl.Columns.Append col&lt;BR /&gt;
....&lt;BR /&gt;
You can then open the file with ADO to write your info&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
Saludos, Ing. Jorge Jimenez, SICAD S.A., Costa Rica&lt;BR /&gt;
&lt;BR /&gt;
&lt;AUBELEC&gt; wrote in message news:5207082@discussion.autodesk.com...&lt;BR /&gt;
Hello.&lt;BR /&gt;
How créate a ADO connection for create un file .XLS ?&lt;BR /&gt;
I know how read a existing file XLS.&lt;BR /&gt;
SQL command : SELEC * ...  but if i use CREATE TABLE...&lt;BR /&gt;
the vba say : the file open only in read.&lt;BR /&gt;
&lt;BR /&gt;
dim strfile as string&lt;BR /&gt;
Dim cnn As New ADODB.Connection&lt;BR /&gt;
dim rs as new ADODB.Recordset&lt;BR /&gt;
strfile=c:\mynewfile.xls&lt;BR /&gt;
cnn.ConnectionString = "Driver={Microsoft Excel Driver (*.xls)};DBQ=" &amp;amp; &lt;BR /&gt;
strfile"&lt;BR /&gt;
cnn.open&lt;BR /&gt;
rs.open "Create table ..."&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
How create a file .XLS without the excel application ?&lt;/AUBELEC&gt;</description>
      <pubDate>Thu, 15 Jun 2006 18:02:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/ado-connection-create-file-excel/m-p/1675932#M33582</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-15T18:02:46Z</dc:date>
    </item>
    <item>
      <title>Re: ADO Connection Create File Excel</title>
      <link>https://forums.autodesk.com/t5/vba-forum/ado-connection-create-file-excel/m-p/1675933#M33583</link>
      <description>Hello the soluce for you. from Help file of Acces (Ms Office) :&lt;BR /&gt;
&lt;BR /&gt;
Sub Main()&lt;BR /&gt;
    On Error GoTo CreateAutoIncrColumnError&lt;BR /&gt;
&lt;BR /&gt;
    Dim cnn As New ADODB.Connection&lt;BR /&gt;
    Dim cat As New ADOX.Catalog&lt;BR /&gt;
    Dim tbl As New ADOX.Table&lt;BR /&gt;
    &lt;BR /&gt;
    cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" &amp;amp; "Data Source=" &amp;amp; "C:\Test.XLS"  &amp;amp; ";Extended Properties=Excel 8.0"    Set cat.ActiveConnection = cnn&lt;BR /&gt;
    &lt;BR /&gt;
    With tbl&lt;BR /&gt;
        .Name = "MyContacts"&lt;BR /&gt;
        Set .ParentCatalog = cat&lt;BR /&gt;
        ' Create fields and append them to the new Table object.&lt;BR /&gt;
        .Columns.Append "ContactId", adInteger&lt;BR /&gt;
        ' Make the ContactId column and auto incrementing column&lt;BR /&gt;
        .Columns("ContactId").Properties("AutoIncrement") = True&lt;BR /&gt;
        .Columns.Append "CustomerID", adVarWChar&lt;BR /&gt;
        .Columns.Append "FirstName", adVarWChar&lt;BR /&gt;
        .Columns.Append "LastName", adVarWChar&lt;BR /&gt;
        .Columns.Append "Phone", adVarWChar, 20&lt;BR /&gt;
        .Columns.Append "Notes", adLongVarWChar&lt;BR /&gt;
    End With&lt;BR /&gt;
    &lt;BR /&gt;
    cat.Tables.Append tbl&lt;BR /&gt;
    &lt;BR /&gt;
 &lt;BR /&gt;
    'Clean up&lt;BR /&gt;
    cnn.Close&lt;BR /&gt;
    Set cat = Nothing&lt;BR /&gt;
    Set tbl = Nothing&lt;BR /&gt;
    Set cnn = Nothing&lt;BR /&gt;
    Exit Sub&lt;BR /&gt;
    &lt;BR /&gt;
CreateAutoIncrColumnError:&lt;BR /&gt;
    &lt;BR /&gt;
    Set cat = Nothing&lt;BR /&gt;
    Set tbl = Nothing&lt;BR /&gt;
&lt;BR /&gt;
    If Not cnn Is Nothing Then&lt;BR /&gt;
        If cnn.State = adStateOpen Then cnn.Close&lt;BR /&gt;
    End If&lt;BR /&gt;
    Set cnn = Nothing&lt;BR /&gt;
    &lt;BR /&gt;
    If Err  0 Then&lt;BR /&gt;
        MsgBox Err.Source &amp;amp; "--&amp;gt;" &amp;amp; Err.Description, , "Error"&lt;BR /&gt;
    End If&lt;BR /&gt;
    &lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
100% working.  (just need a corret file/path.) + &lt;BR /&gt;
Add Ref :  (Menu Tools - Réf)&lt;BR /&gt;
Microsoft ADO +&lt;BR /&gt;
Microsoft ADO Ext</description>
      <pubDate>Mon, 19 Jun 2006 12:10:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/ado-connection-create-file-excel/m-p/1675933#M33583</guid>
      <dc:creator>Aubelec</dc:creator>
      <dc:date>2006-06-19T12:10:34Z</dc:date>
    </item>
  </channel>
</rss>

