{"id":54353,"date":"2009-02-19T21:15:00","date_gmt":"2009-02-19T21:15:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2009\/02\/19\/hey-scripting-guy-how-can-i-import-data-into-office-access-from-office-excel\/"},"modified":"2009-02-19T21:15:00","modified_gmt":"2009-02-19T21:15:00","slug":"hey-scripting-guy-how-can-i-import-data-into-office-access-from-office-excel","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/hey-scripting-guy-how-can-i-import-data-into-office-access-from-office-excel\/","title":{"rendered":"Hey, Scripting Guy! How Can I Import Data into Office Access from Office Excel?"},"content":{"rendered":"<h2><img decoding=\"async\" class=\"nearGraphic\" title=\"Hey, Scripting Guy! Question\" border=\"0\" alt=\"Hey, Scripting Guy! Question\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" width=\"34\" height=\"34\"> <\/h2>\n<p>Hey, Scripting Guy! I need to do hardware inventory on all our workstations and on all our servers. I know <a href=\"http:\/\/www.microsoft.com\/systemcenter\/configurationmanager\/en\/us\/default.aspx\">System Center Configuration Manager<\/a> can do this and a whole lot more. We actually have it budgeted for deployment next year. However, that does not help me now. We had a summer intern that went around and typed a lot of information such as make, model, and serial number into an Office Excel spreadsheet. In fact that is about all he did was go around typing information into an Office Excel spreadsheet, and it has been a big help to us. But I would like more information, and I do not have the time or the patience to type a bunch of information into a spreadsheet. What I would really like is to have the information in a database instead of an Office Excel spreadsheet. Can you figure out a way to import the data from Office Excel into Office Access?<\/p>\n<p>&#8211; JS<\/p>\n<p><img decoding=\"async\" border=\"0\" alt=\"Spacer\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/05\/spacer.gif\" width=\"5\" height=\"5\"><img decoding=\"async\" class=\"nearGraphic\" title=\"Hey, Scripting Guy! Answer\" border=\"0\" alt=\"Hey, Scripting Guy! Answer\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" width=\"34\" height=\"34\"><\/p>\n<p>Hi JS,<\/p>\n<p>When the trumpet call split the air with the message that the minister of state was within sight and that Leonore had saved her husband, the audience of <a href=\"http:\/\/en.wikipedia.org\/wiki\/Fidelio\" target=\"_blank\">Fidelio<\/a> readily appreciated they had just witnessed one of the great scenes of opera. It is a defining moment when one has arrived at perfect clarity, unity of purpose, and symmetry as <a href=\"http:\/\/encarta.msn.com\/encyclopedia_761551951\/Beethoven.html\" target=\"_blank\">Beethoven<\/a> did when he wrote his only opera. <\/p>\n<p>        var sortedCol = new Array();        var sortFactor = new Array();        var initialSort = new Array();        function rowData(index, value)        {        this.index = index;        this.value = value;        }        var compareFactor;        function compareValues(a, b)        {        if (a.value <b> b.value)        return compareFactor;        return 0;        }        function sortByColumn(tableIndex, tdName, order)        {                  var td = document.getElementById(tdName);          var cols = td.parentElement.children;          var col = -1;          for (var i=0; i &lt; cols.length; i++)          if (cols[i] == td)          col = i;          if (col == -1)          return;          if (td != sortedCol[tableIndex] &amp;&amp; sortedCol[tableIndex] != null)          {          sortedCol[tableIndex].className = &quot;sortable&quot;;          sortedCol[tableIndex].getElementsByTagName(&quot;IMG&quot;)[0].src=&quot;http:\/\/blogs.technet.com\/library\/gallery\/templates\/MNP2.GenericArticle\/..\/MNP2.Common\/images\/sortNone.gif&quot;;          }          if (td == sortedCol[tableIndex])          {          sortFactor[tableIndex] = -sortFactor[tableIndex];          }          else          {          sortedCol[tableIndex] = td;          if (!initialSort) sortFactor[tableIndex] = 1;          td.className = &quot;selectedSort&quot;;          }          if (sortFactor[tableIndex] == 1)          td.getElementsByTagName(&quot;IMG&quot;)[0].src=&quot;http:\/\/blogs.technet.com\/library\/gallery\/templates\/MNP2.GenericArticle\/..\/MNP2.Common\/images\/sortAscending.gif&quot;;          else          td.getElementsByTagName(&quot;IMG&quot;)[0].src=&quot;http:\/\/blogs.technet.com\/library\/gallery\/templates\/MNP2.GenericArticle\/..\/MNP2.Common\/images\/sortDescending.gif&quot;;          initialSort = false;          var thead = td.parentElement.parentElement;          var tbody = thead.nextSibling;          var table = thead.parentElement;          var rows = tbody.getElementsByTagName(&quot;TR&quot;);          var data = new Array();          var hasEvenRowShading = false;          for (var i=0; i &lt; rows.length; i++)          if (rows[i].parentElement == tbody)          {          if (rows[i].className == &quot;evenRecord&quot;)          hasEvenRowShading = true;          var cell = rows[i].children[col];          var value = cell.getAttribute(&quot;value&quot;);          if (value == null)          value = cell.innerText;          if (order == &#039;numerical&#039;)          {          var filterChars = new Array(&quot;$&quot;, &quot;\u00a2&quot;, &quot;\u00a3&quot;, &quot;\u00a4&quot;, &quot;\u00a5&quot;, &quot;&#8355;&quot;, &quot;&#8356;&quot;, &quot;&#8359;&quot;, &quot;&#8362;&quot;, &quot;&#8363;&quot;, &quot;&#8364;&quot;, &quot;,&quot;, &quot;.&quot;);          for (var j=0; j &lt; filterChars.length; j++)          value = value.replace(filterChars[j], &quot;&quot;);          value = parseFloat(value);          if (isNaN(value))          value = Number.NEGATIVE_INFINITY;          }          if (order == &#039;chronological&#039;)          value = Date.parse(value);          data[i] = new rowData(i, value);          }          compareFactor = sortFactor[tableIndex];          data = data.sort(compareValues);          var tbody2 = document.createElement(&quot;TBODY&quot;);          for (var i=0; i &lt; data.length; i++)          if (data[i])          {          var row = rows[data[i].index].cloneNode(true);          if ((i % 2 == 0) || !hasEvenRowShading)          row.className = &quot;record&quot;;          else          row.className = &quot;evenRecord&quot;;          tbody2.appendChild(row);          }          table.replaceChild(tbody2, tbody);                }      <\/p>\n<table id=\"EED\" class=\"dataTable\" cellSpacing=\"0\" cellPadding=\"0\">\n<thead><\/thead>\n<tbody>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">This week we will be talking about scripting Microsoft Office Access. The <a href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/db.mspx\" target=\"_blank\">Databases hub<\/a> is a great jumping-off point because it highlights the available Office Access scripts we have in the TechNet Script Center. There are also links to the Office Access scripts we have in the <a href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/scripts\/misc\/database\/default.mspx?mfr=true\" target=\"_blank\">Script Center Script Repository<\/a> and on the <a href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/csc\/scripts\/databases\/default.mspx\" target=\"_blank\">Community-Submitted Scripts Center<\/a>. When taken as a whole, there are tons of examples for you to review. For information about downloading and installing Windows PowerShell, you can go to the <a href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx\" target=\"_blank\">Windows PowerShell Scripting Hub<\/a>.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"dataTableBottomMargin\"><\/div>\n<p>JS, you have had such a defining moment in boiling down the essence of your needs. We will be glad to be your Leonore and save you from spreadsheet prison.<\/p>\n<p>The <b>ImportSpreadSheetToAccess.ps1<\/b> script is seen here.<\/p>\n<pre class=\"codeSample\">$Import = 0\n$SpreadSheetType = 8\n$TableName = \"MyTest\"\n$FileName = \"C:\\Fso\\Test.xls\"\n$HasFieldNames = $True\n$Range = \"A1:C29\"\n$access = New-Object -ComObject Access.Application\n$Access.OpenCurrentDataBase(\"C:\\fso\\Test.mdb\")\n$Access.DoCmd.TransferSpreadSheet($Import, $SpreadSheetType, $TableName, $FileName,$HasFieldNames,$Range)\n$Access.Quit()\n<\/pre>\n<p>In the <b>ImportSpreadSheetToAccess.ps1<\/b> script, we import an Office Excel spreadsheet containing the data, such as seen here:<\/p>\n<p><img decoding=\"async\" border=\"0\" alt=\"Image of the imported Office Excel spreadsheet\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/qanda\/hsg\/2009\/february\/hey0219\/hsg-2-19-9-01.jpg\" width=\"500\" height=\"357\"><\/p>\n<p>&nbsp;<\/p>\n<p>The first thing we do in this script is define a few variables and assign the appropriate values to them. These values will all be used when we get to the <b>DoCmd.TransferSpreadSheet<\/b> method. For now, we are simply assigning various strings and integers to some variables. In Windows PowerShell, all variables begin with a dollar sign. We will talk about these variable values in just a little bit.<\/p>\n<pre class=\"codeSample\">$Import = 0\n$SpreadSheetType = 8\n$TableName = \"MyTest\"\n$FileName = \"C:\\Fso\\Test.xls\"\n$HasFieldNames = $True\n$Range = \"A1:C29\"\n<\/pre>\n<p>We next create an instance of the <b>Access.Application<\/b> object. This is the main object we use when working with the Access automation model. The <b>Access.Application<\/b> object is documented <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/bb214165.aspx\" target=\"_blank\">on MSDN<\/a>. To create the <b>Access.Application<\/b> object, we use the <b>New-Object<\/b> cmdlet and the <b>ComObject<\/b> parameter. The <b>ComObject<\/b> parameter tells the <b>New-Object<\/b> cmdlet that we are creating a COM object. If you are using the same kind of object you used in an old VBScript script, it is a COM object. The code that creates this object is seen here:<\/p>\n<pre class=\"codeSample\">$access = New-Object -ComObject Access.Application<\/pre>\n<p>If you are not sure whether you have a COM object and do not want to see an error, use the <b>ComObject<\/b> parameter. If you actually have a .NET Framework class, the <b>ComObject<\/b> parameter will be ignored. Pretty cool, huh? You want an example? Okay. <b>System.Random<\/b> is a .NET Framework class, but as you can see here, we use <b>New-Object<\/b> and the <b>ComObject<\/b> parameter and pipe the results to <b>Get-Member<\/b>. We see the members of the <b>System.Random<\/b> class. We next assign the object to the variable <b>$a<\/b> and call the <b>Next<\/b> method, generating the next random number. This proves that Windows PowerShell ignores the <b>ComObject<\/b> parameter when working with a .NET Framework class:<\/p>\n<pre class=\"codeSample\">PS C:\\&gt; New-Object -ComObject System.Random | Get-Member\n   TypeName: System.Random\nName        MemberType Definition\n----        ---------- ----------\nEquals      Method     System.Boolean Equals(Object obj)\nGetHashCode Method     System.Int32 GetHashCode()\nGetType     Method     System.Type GetType()\nNext        Method     System.Int32 Next(), System.Int32 Next(Int32 minValue, Int32 maxValue), System.Int32 Next(Int...\nNextBytes   Method     System.Void NextBytes(Byte[] buffer)\nNextDouble  Method     System.Double NextDouble()\nToString    Method     System.String ToString()\nPS C:\\&gt; $a = New-Object -ComObject System.Random\nPS C:\\&gt; $a.Next()\n1273012407\n<\/pre>\n<p>After have created the <b>Access.Application<\/b> object, we use the <b>OpenCurrentDataBase<\/b> method to open the database (no surprise there):<\/p>\n<pre class=\"codeSample\">$Access.OpenCurrentDataBase(\"C:\\fso\\Test.mdb\")<\/pre>\n<p>After we have opened the database, we use the <b>DoCmd<\/b> object. The <b>DoCmd<\/b> object is a remarkable object that has the ability to perform a large number of different commands. The methods are seen in <b>Table 1<\/b>. More information about the <b>DoCmd<\/b> object can be found <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/bb258521.aspx\" target=\"_blank\">on MSDN<\/a>.<\/p>\n<table id=\"ELH\" class=\"dataTable\" cellSpacing=\"0\" cellPadding=\"0\">\n<thead>\n<tr>\n<td class=\"tableHeader\" colSpan=\"2\">Table 1 Access Application object DoCmd methods<\/td>\n<\/tr>\n<tr class=\"stdHeader\" vAlign=\"top\">\n<td id=\"colEOH\">Name<\/td>\n<td id=\"colESH\">Description<\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">AddMenu<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>AddMenu<\/b> method carries out the <b>AddMenu<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">ApplyFilter<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>ApplyFilter<\/b> method carries out the <b>ApplyFilter<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">Beep<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>Beep<\/b> method carries out the <b>Beep<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">CancelEvent<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>CancelEvent<\/b> method carries out the <b>CancelEvent<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">ClearMacroError<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Removes information about an error that is stored in the <b>MacroError<\/b> object.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">Close<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>Close<\/b> method carries out the <b>Close<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">CloseDatabase<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Closes the current database.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">CopyDatabaseFile<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Copies the database connected to the current project to a Microsoft SQL Server database file for export.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">CopyObject<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>CopyObject<\/b> method carries out the <b>CopyObject<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">DeleteObject<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>DeleteObject<\/b> method carries out the <b>DeleteObject<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">DoMenuItem<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Displays the appropriate menu or toolbar command for Microsoft Access.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">Echo<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Carries out the <b>Echo<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">FindNext<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>FindNext<\/b> method carries out the <b>FindNext<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">FindRecord<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>FindRecord<\/b> method carries out the <b>FindRecord<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">GoToControl<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>GoToControl<\/b> method carries out the <b>GoToControl<\/b> action action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">GoToPage<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Carries out the <b>GoToPage<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">GoToRecord<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>GoToRecord<\/b> method carries out the <b>GoToRecord<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">Hourglass<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>Hourglass<\/b> method carries out the <b>Hourglass<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">LockNavigationPane<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">You can use the <b>LockNavigationPane<\/b> action to prevent users from deleting database objects that are displayed in the Navigation Pane.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">Maximize<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>Maximize<\/b> method carries out the <b>Maximize<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">Minimize<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>Minimize<\/b> method carries out the <b>Minimize<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">MoveSize<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>MoveSize<\/b> method carries out the <b>MoveSize<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">NavigateTo<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">You can use the <b>NavigateTo<\/b> method to control the display of database objects in the Navigation Pane.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">OpenDataAccessPage<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>OpenDataAccessPage<\/b> method carries out the <b>OpenDataAccessPage<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">OpenDiagram<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>OpenDiagram<\/b> method carries out the <b>OpenDiagram<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">OpenForm<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>OpenForm<\/b> method carries out the <b>OpenForm<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">OpenFunction<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Opens a user-defined function in a Microsoft SQL Server database for viewing in Microsoft Office Access.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">OpenModule<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>OpenModule<\/b> method carries out the <b>OpenModule<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">OpenQuery<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>OpenQuery<\/b> method carries out the <b>OpenQuery<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">OpenReport<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>OpenReport<\/b> method carries out the <b>OpenReport<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">OpenStoredProcedure<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>OpenStoredProcedure<\/b> method carries out the <b>OpenStoredProcedure<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">OpenTable<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>OpenTable<\/b> method carries out the <b>OpenTable<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">OpenView<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>OpenView<\/b> method carries out the <b>OpenView<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">OutputTo<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>OutputTo<\/b> method carries out the <b>OutputTo<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">Printout<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>PrintOut<\/b> method carries out the <b>PrintOut<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">Quit<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>Quit<\/b> method quits Microsoft Access. You can select one of several options for saving a database object before quitting.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">Rename<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>Rename<\/b> method carries out the <b>Rename<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">RepaintObject<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>RepaintObject<\/b> method carries out the <b>RepaintObject<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">Requery<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Carries out the <b>Requery<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">Restore<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>Restore<\/b> method carries out the <b>Restore<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">RunCommand<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>RunCommand<\/b> method runs a built-in command.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">RunMacro<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>RunMacro<\/b> method carries out the <b>RunMacro<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">RunSavedImportExport<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Runs a saved import or export specification.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">RunSQL<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>RunSQL<\/b> method carries out the <b>RunSQL<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">Save<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>Save<\/b> method carries out the <b>Save<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">SearchForRecord<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">You can use the <b>SearchForRecord<\/b> method to search for a specific record in a table, query, form, or report.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">SelectObject<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>SelectObject<\/b> method carries out the <b>SelectObject<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">SendObject<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>SendObject<\/b> method carries out the <b>SendObject<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">SetDisplayedCategories<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Specifies which categories are displayed under Navigate to Category in the title bar of the Navigation Pane.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">SetMenuItem<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>SetMenuItem<\/b> method carries out the <b>SetMenuItem<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">SetProperty<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>SetProperty<\/b> method carries out the <b>SetProperty<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">SetWarnings<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>SetWarnings<\/b> method carries out the <b>SetWarnings<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">ShowAllRecords<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>ShowAllRecords<\/b> method carries out the <b>ShowAllRecords<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">ShowToolbar<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>ShowToolbar<\/b> method carries out the <b>ShowToolbar<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">SingleStep<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Pauses macro execution and opens the Macro Single Step dialog box.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">StartNewWorkFlow<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Displays the Start New Workflow dialog box.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">TransferDatabase<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>TransferDatabase<\/b> method carries out the <b>TransferDatabase<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">TransferSharePointList<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">You can use the <b>TransferSharePointList<\/b> method to import or link data from a 1st_WSS_3 site.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">TransferSpreadsheet<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>TransferSpreadsheet<\/b> method carries out the <b>TransferSpreadsheet<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">TransferSQLDatabase<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Transfers the entire specified Microsoft SQL Server database to another SQL Server database.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">TransferText<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The <b>TransferText<\/b> method carries out the <b>TransferText<\/b> action in Visual Basic.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">WorkflowTasks<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Displays the Workflow Tasks dialog box.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"dataTableBottomMargin\"><\/div>\n<p>The <b>TransferSpreadSheet<\/b> method from the <b>DoCmd<\/b> object has a signature that accepts seven optional arguments. The argument names, data types, and descriptions are seen in <b>Table 2<\/b>.<\/p>\n<p>        var tableId = &#8220;EIEAE&#8221;;        sortedCol[tableId] = null;        sortFactor[tableId] = 1;        initialSort[tableId] = true;      <\/p>\n<table id=\"EIEAE\" class=\"dataTable\" cellSpacing=\"0\" cellPadding=\"0\">\n<thead>\n<tr>\n<td class=\"tableHeader\" colSpan=\"3\">Table 2 TransferSpreadSheet Method arguments<\/td>\n<\/tr>\n<tr class=\"sortable\" vAlign=\"top\">\n<td id=\"colEMEAE\" class=\"sortable\"><a href=\"sortByColumn('EIEAE', 'colEMEAE', '')\"><\/p>\n<table cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\">\n<tbody>\n<tr>\n<td width=\"100%\">Name<\/td>\n<td align=\"right\"><img decoding=\"async\" title=\"\" alt=\"*\" src=\"http:\/\/www.microsoft.com\/library\/gallery\/templates\/MNP2.Common\/images\/sortNone.gif\" width=\"8\" height=\"8\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><\/a><\/td>\n<td id=\"colEQEAE\" class=\"sortable\"><a href=\"sortByColumn('EIEAE', 'colEQEAE', '')\"><\/p>\n<table cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\">\n<tbody>\n<tr>\n<td width=\"100%\">Data Type<\/td>\n<td align=\"right\"><img decoding=\"async\" title=\"\" alt=\"*\" src=\"http:\/\/www.microsoft.com\/library\/gallery\/templates\/MNP2.Common\/images\/sortNone.gif\" width=\"8\" height=\"8\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><\/a><\/td>\n<td id=\"colEUEAE\" class=\"sortable\"><a href=\"sortByColumn('EIEAE', 'colEUEAE', '')\"><\/p>\n<table cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\">\n<tbody>\n<tr>\n<td width=\"100%\">Description<\/td>\n<td align=\"right\"><img decoding=\"async\" title=\"\" alt=\"*\" src=\"http:\/\/www.microsoft.com\/library\/gallery\/templates\/MNP2.Common\/images\/sortNone.gif\" width=\"8\" height=\"8\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><\/a><\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">TransferType<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">AcDataTransferType<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The type of transfer you want to make. The default value is acImport.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">SpreadsheetType<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">AcSpreadSheetType<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The type of spreadsheet to import from, export to, or link to.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">TableName<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Variant<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">A string expression that is the name of the Microsoft Office Access table you want to import spreadsheet data into, export spreadsheet data from, or link spreadsheet data to, or the Office Access select query whose results you want to export to a spreadsheet.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">FileName<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Variant<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">A string expression that&#8217;s the file name and path of the spreadsheet you want to import from, export to, or link to.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">HasFieldNames<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Variant<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Use True (\u20131) to use the first row of the spreadsheet as field names when importing or linking. Use False (0) to treat the first row of the spreadsheet as normal data. If you leave this argument blank, the default (False) is assumed. When you export Access table or select query data to a spreadsheet, the field names are inserted into the first row of the spreadsheet, no matter what you enter for this argument.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">Range<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Variant<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">A string expression that&#8217;s a valid range of cells or the name of a range in the spreadsheet. This argument applies only to importing. Leave this argument blank to import the entire spreadsheet. When you export to a spreadsheet, you must leave this argument blank. If you enter a range, the export will fail.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">UseOA<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Variant<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">This argument is not supported.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"dataTableBottomMargin\"><\/div>\n<p>The <b>TransferSpreadSheet<\/b> method signature is seen here:<\/p>\n<pre class=\"codeSample\">expression.TransferSpreadsheet(TransferType, SpreadsheetType, TableName, FileName, HasFieldNames, Range, UseOA)<\/pre>\n<p>The first argument is the <b>TransferType<\/b> argument, which can take three potential values. These values need to be an instance of the <b>AcDataTransferType<\/b> enumeration. These enumeration values are seen in <b>Table 3<\/b>. In our script, we use the variable named <b>$import<\/b> and gave it the value of 1. From <b>Table 3<\/b> we can tell that a value of 1 means the data is exported.<\/p>\n<p>        var tableId = &#8220;EBHAE&#8221;;        sortedCol[tableId] = null;        sortFactor[tableId] = 1;        initialSort[tableId] = true;      <\/p>\n<table id=\"EBHAE\" class=\"dataTable\" cellSpacing=\"0\" cellPadding=\"0\">\n<thead>\n<tr>\n<td class=\"tableHeader\" colSpan=\"3\">Table 3 TransferSpreadSheet method TransferType enumeration values<\/td>\n<\/tr>\n<tr class=\"sortable\" vAlign=\"top\">\n<td id=\"colEFHAE\" class=\"sortable\"><a href=\"sortByColumn('EBHAE', 'colEFHAE', '')\"><\/p>\n<table cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\">\n<tbody>\n<tr>\n<td width=\"100%\">Name<\/td>\n<td align=\"right\"><img decoding=\"async\" title=\"\" alt=\"*\" src=\"http:\/\/www.microsoft.com\/library\/gallery\/templates\/MNP2.Common\/images\/sortNone.gif\" width=\"8\" height=\"8\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><\/a><\/td>\n<td id=\"colEJHAE\" class=\"sortable\"><a href=\"sortByColumn('EBHAE', 'colEJHAE', '')\"><\/p>\n<table cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\">\n<tbody>\n<tr>\n<td width=\"100%\">Value<\/td>\n<td align=\"right\"><img decoding=\"async\" title=\"\" alt=\"*\" src=\"http:\/\/www.microsoft.com\/library\/gallery\/templates\/MNP2.Common\/images\/sortNone.gif\" width=\"8\" height=\"8\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><\/a><\/td>\n<td id=\"colENHAE\" class=\"sortable\"><a href=\"sortByColumn('EBHAE', 'colENHAE', '')\"><\/p>\n<table cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\">\n<tbody>\n<tr>\n<td width=\"100%\">Description<\/td>\n<td align=\"right\"><img decoding=\"async\" title=\"\" alt=\"*\" src=\"http:\/\/www.microsoft.com\/library\/gallery\/templates\/MNP2.Common\/images\/sortNone.gif\" width=\"8\" height=\"8\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><\/a><\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">acExport<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">1<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The data is exported.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">acImport<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">0<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">(Default) The data is imported.<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">acLink<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">2<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">The database is linked to the specified data source.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"dataTableBottomMargin\"><\/div>\n<p>The second argument is the <b>Spreadsheet<\/b> argument. There are 10 different enumerations listed. but only 8 different values. You will also notice from <b>Table 4<\/b> that the Office 2007 formatted spreadsheet is not a supported format. This is why our spreadsheet is an .xls file and was saved in Office Excel 2000 format.<\/p>\n<p>        var tableId = &#8220;EPIAE&#8221;;        sortedCol[tableId] = null;        sortFactor[tableId] = 1;        initialSort[tableId] = true;      <\/p>\n<table id=\"EPIAE\" class=\"dataTable\" cellSpacing=\"0\" cellPadding=\"0\">\n<thead>\n<tr>\n<td class=\"tableHeader\" colSpan=\"3\">Table 4 TransferSpreadSheet method SpreadsheetType enumeration values<\/td>\n<\/tr>\n<tr class=\"sortable\" vAlign=\"top\">\n<td id=\"colETIAE\" class=\"sortable\"><a href=\"sortByColumn('EPIAE', 'colETIAE', '')\"><\/p>\n<table cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\">\n<tbody>\n<tr>\n<td width=\"100%\">Name<\/td>\n<td align=\"right\"><img decoding=\"async\" title=\"\" alt=\"*\" src=\"http:\/\/www.microsoft.com\/library\/gallery\/templates\/MNP2.Common\/images\/sortNone.gif\" width=\"8\" height=\"8\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><\/a><\/td>\n<td id=\"colEXIAE\" class=\"sortable\"><a href=\"sortByColumn('EPIAE', 'colEXIAE', '')\"><\/p>\n<table cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\">\n<tbody>\n<tr>\n<td width=\"100%\">Value<\/td>\n<td align=\"right\"><img decoding=\"async\" title=\"\" alt=\"*\" src=\"http:\/\/www.microsoft.com\/library\/gallery\/templates\/MNP2.Common\/images\/sortNone.gif\" width=\"8\" height=\"8\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><\/a><\/td>\n<td id=\"colE2IAE\" class=\"sortable\"><a href=\"sortByColumn('EPIAE', 'colE2IAE', '')\"><\/p>\n<table cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\">\n<tbody>\n<tr>\n<td width=\"100%\">Description<\/td>\n<td align=\"right\"><img decoding=\"async\" title=\"\" alt=\"*\" src=\"http:\/\/www.microsoft.com\/library\/gallery\/templates\/MNP2.Common\/images\/sortNone.gif\" width=\"8\" height=\"8\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><\/a><\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">acSpreadsheetTypeExcel3<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">0<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Microsoft Excel 3.0 format<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">acSpreadsheetTypeExcel4<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">6<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Microsoft Excel 4.0 format<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">acSpreadsheetTypeExcel5<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">5<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Microsoft Excel 5.0 format<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">acSpreadsheetTypeExcel7<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">5<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Microsoft Excel 95 format<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">acSpreadsheetTypeExcel8<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">8<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Microsoft Excel 97 format<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">acSpreadsheetTypeExcel9<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">8<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Microsoft Excel 2000 format<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">acSpreadsheetTypeLotusWJ2<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">4<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Japanese version only<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">acSpreadsheetTypeLotusWK1<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">2<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Lotus 1-2-3 WK1 format<\/p>\n<\/td>\n<\/tr>\n<tr class=\"record\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">acSpreadsheetTypeLotusWK3<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">3<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Lotus 1-2-3 WK3 format<\/p>\n<\/td>\n<\/tr>\n<tr class=\"evenRecord\" vAlign=\"top\">\n<td>\n<p class=\"lastInCell\">acSpreadsheetTypeLotusWK4<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">7<\/p>\n<\/td>\n<td>\n<p class=\"lastInCell\">Lotus 1-2-3 WK4 format<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"dataTableBottomMargin\"><\/div>\n<p>We could have used the <b>Enumerations<\/b> directly by first loading the <b>Access Interop<\/b> assembly. To do this in Windows PowerShell 1.0, we can use the <b>LoadWithPartialName<\/b> static method from the <b>Reflection.Assembly<\/b> .NET Framework class. After we have loaded the <b>Interop<\/b> assembly, we can create the two enumeration classes as seen here:<\/p>\n<pre class=\"codeSample\">[Reflection.Assembly]::LoadWithPartialName(\"Microsoft.Office.Interop.Access\") | Out-Null\n$AcDataTransferType = \"Microsoft.Office.Interop.Access.AcDataTransferType\" -as [type]\n$AcSpreadSheetType = \"Microsoft.Office.Interop.Access.AcSpreadSheetType\" -as [type]\n<\/pre>\n<p>If we had done that, we could then call the <b>TransferSpreadSheet<\/b> method and used the enumeration values directly; the TransferSpreadSheet method call would have looked like the following:<\/p>\n<pre class=\"codeSample\">$Access.DoCmd.TransferSpreadSheet($AcDataTransferType::acImport,\n$AcSpreadSheetType::AcSpreadSheetTypeExcel9, $TableName, $FileName,$HasFieldNames,$Range)\n<\/pre>\n<p>Instead, for simplicity\u2019s sake, we used the methodology more in keeping with <a href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/resources\/qanda\/apr07\/hey0404.mspx\" target=\"_blank\">the VBScript version of this script<\/a>. The <b>TableName<\/b> is the table name in the Office Access database, and the <b>FileName<\/b> argument is the path and name of the Office Excel spreadsheet to import. The <b>HasFieldNames<\/b> argument is a Boolean value that indicates whether or not the first row of the Office Excel spreadsheet contains the field names. The range is used to specify the range in the Office Excel spreadsheet to import. The first number indicates the upper left cell reference, and the second number is the lower right reference. The <b>method<\/b> call is shown here:<\/p>\n<pre class=\"codeSample\">$Access.DoCmd.TransferSpreadSheet($Import, $SpreadSheetType, $TableName, $FileName,$HasFieldNames,$Range)<\/pre>\n<p>If you have an <b>autonumber<\/b> field in your database, make sure you do not try to import a row from the Office Excel spreadsheet with the same field name or you will get an error. Also pay attention to the data types expected by the fields in the Office Access database, and make sure that your import data matches up. For instance, you will get an error trying to import a string into a field that expects a date type. <\/p>\n<p>After we have imported the spreadsheet, we use the <b>Quit<\/b> method to close out <b>Access.Application<\/b> object. This is a very important step that will prevent multiple copies of Office Access from running:<\/p>\n<pre class=\"codeSample\">$Access.Quit()<\/pre>\n<p>The completed Office Access database with the newly imported data is seen here:<\/p>\n<p><img decoding=\"async\" border=\"0\" alt=\"Image of the completed Office Access database with newly imported data\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/qanda\/hsg\/2009\/february\/hey0219\/hsg-2-19-9-02.jpg\" width=\"500\" height=\"358\"><\/p>\n<p>&nbsp;<\/p>\n<p>Well, JS, this concludes writing to an Office Access database. It also concludes our Office Access Database Week articles. Join us tomorrow for Quick-Hits Friday.&nbsp;<\/p>\n<p><b>Ed Wilson and Craig Liebendorfer, Scripting Guys<\/b><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! I need to do hardware inventory on all our workstations and on all our servers. I know System Center Configuration Manager can do this and a whole lot more. We actually have it budgeted for deployment next year. However, that does not help me now. We had a summer intern that went [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[717,710,54,48,49,3,45],"class_list":["post-54353","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-access-application","tag-excel-spreadsheet","tag-microsoft-access","tag-microsoft-excel","tag-office","tag-scripting-guy","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! I need to do hardware inventory on all our workstations and on all our servers. I know System Center Configuration Manager can do this and a whole lot more. We actually have it budgeted for deployment next year. However, that does not help me now. We had a summer intern that went [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/54353","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=54353"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/54353\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=54353"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=54353"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=54353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}