{"id":67,"date":"2013-10-07T12:30:19","date_gmt":"2013-10-07T11:30:19","guid":{"rendered":"http:\/\/tech-tipps.de\/?p=67"},"modified":"2013-10-07T12:30:19","modified_gmt":"2013-10-07T11:30:19","slug":"excel-datei-in-access2007-neu-einbinden-per-vba","status":"publish","type":"post","link":"https:\/\/tech-tipps.de\/?p=67","title":{"rendered":"Excel-Datei in Access2007 neu einbinden per VBA"},"content":{"rendered":"<div class=\"pntrst_main_before_after\"><\/div><h1>Problem:<\/h1>\n<p>Ich habe als FE eine Access2007 ACCDB und als BE eine SQL2005-Datenbank.<br \/>\nIn meiner FE habe ich ebenfalls eine Excel-Datei verkn\u00fcpft. Aus dieser werden Auftragsdaten, die vom Kunden kommen in die SQL-Datenbank importiert.<\/p>\n<p>Da, sich nun der Speicherort und der Dateiname der Excel-Datei \u00e4ndern k\u00f6nnen, muss der Anwender die M\u00f6glichkeit haben, die Excel-Datei neu einbinden zu k\u00f6nnen.<!--more--><br \/>\n(BTW der Name des Excel-Tabellenblattes bleibt aber immer gleich!).<\/p>\n<p>Ich versuche das mit folgendem Code zu erm\u00f6glichen:<\/p>\n<dl class=\"codebox\" style=\"font: 12px\/16.79px Helvetica, Arial, sans-serif; margin: 0px; padding: 3px; border: 1px solid #c9d2d8; border-image: none; color: #333333; text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: #ffffff; -webkit-text-stroke-width: 0px;\">\n<dt style=\"margin: 0px 0px 3px; padding: 0px; text-transform: uppercase; font-size: 0.8em; font-weight: bold; border-bottom-color: #cccccc; border-bottom-width: 1px; border-bottom-style: solid; display: block;\">CODE:<\/dt>\n<dd style=\"margin: 0px; padding: 0px;\"><code style=\"font: 0.9em\/1.3em Monaco, 'Andale Mono', 'Courier New', Courier, mono; margin: 2px 0px; padding: 5px 0px 0px; height: auto; color: #2e8b57; overflow: auto; display: block; white-space: normal; max-height: 200px;\">Public Function ExcelNeuEinbinden(AcTabName As String, FullPathName As String)<span class=\"Apple-converted-space\">\u00a0<\/span><br style=\"margin: 0px; padding: 0px;\" \/>\u00a0 \u00a0 Dim ConStr As String<span class=\"Apple-converted-space\">\u00a0<\/span><br style=\"margin: 0px; padding: 0px;\" \/>\u00a0 \u00a0<br style=\"margin: 0px; padding: 0px;\" \/>\u00a0 \u00a0 ConStr = CurrentDb.TableDefs(AcTabName).Connect<span class=\"Apple-converted-space\">\u00a0<\/span><br style=\"margin: 0px; padding: 0px;\" \/>\u00a0 \u00a0 CurrentDb.TableDefs(AcTabName).Connect = Mid(ConStr, 1, InStr(ConStr, \"DATABASE=\") + 8) &amp; FullPathName<span class=\"Apple-converted-space\">\u00a0<\/span><br style=\"margin: 0px; padding: 0px;\" \/>\u00a0 \u00a0 CurrentDb.TableDefs(AcTabName).RefreshLink<span class=\"Apple-converted-space\">\u00a0<\/span><br style=\"margin: 0px; padding: 0px;\" \/>End Function<\/code><\/dd>\n<\/dl>\n<p><br style=\"font: 12px\/16.79px Helvetica, Arial, sans-serif; margin: 0px; padding: 0px; color: #333333; text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: #ffffff; -webkit-text-stroke-width: 0px;\" \/><br \/>\nDie Funktion l\u00e4uft ohne Probleme ab, es kommt keine Fehlermeldung und mit DebugPrint konnte ich feststellen, dass alle Variablen richtig gef\u00fcllt werden.<\/p>\n<p>ABER:<br \/>\nEs passiert nichts\u00a0<img decoding=\"async\" title=\"Sad\" alt=\":(\" src=\"http:\/\/alt.tech-tipps.de\/images\/smilies\/icon_e_sad.gif\" \/><br \/>\nSoll hei\u00dfen, die Connect-Eigenschaft meiner verkn\u00fcpften Excel-Tabelle bleibt gleich.<\/p>\n<h1>L\u00f6sung:<\/h1>\n<p>Eine wirkliche L\u00f6sung f\u00fcr den &#8222;Fehler&#8220; im Code habe ich nicht,<br \/>\naber daf\u00fcr habe ich eine L\u00f6sung des Problems!!!\u00a0<img decoding=\"async\" title=\"Very Happy\" alt=\":D\" src=\"http:\/\/alt.tech-tipps.de\/images\/smilies\/icon_e_biggrin.gif\" \/><\/p>\n<p>Ich mach&#8217;s jetzt mit:<\/p>\n<dl class=\"codebox\" style=\"font: 12px\/16.79px Helvetica, Arial, sans-serif; margin: 0px; padding: 3px; border: 1px solid #c9d2d8; border-image: none; color: #333333; text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: #ffffff; -webkit-text-stroke-width: 0px;\">\n<dt style=\"margin: 0px 0px 3px; padding: 0px; text-transform: uppercase; font-size: 0.8em; font-weight: bold; border-bottom-color: #cccccc; border-bottom-width: 1px; border-bottom-style: solid; display: block;\">CODE:<\/dt>\n<dd style=\"margin: 0px; padding: 0px;\"><code style=\"font: 0.9em\/1.3em Monaco, 'Andale Mono', 'Courier New', Courier, mono; margin: 2px 0px; padding: 5px 0px 0px; height: auto; color: #2e8b57; overflow: auto; display: block; white-space: normal; max-height: 200px;\">Public Sub ExcelNeuEinbinden()<br style=\"margin: 0px; padding: 0px;\" \/>\u00a0 \u00a0 \u00a0Dim db As Database<br style=\"margin: 0px; padding: 0px;\" \/>\u00a0 \u00a0 \u00a0<br style=\"margin: 0px; padding: 0px;\" \/>\u00a0 \u00a0 \u00a0Set db = CurrentDb<br style=\"margin: 0px; padding: 0px;\" \/>\u00a0 \u00a0 \u00a0db.TableDefs.Delete Tabellenname<br style=\"margin: 0px; padding: 0px;\" \/>\u00a0 \u00a0 \u00a0db.TableDefs.Refresh<br style=\"margin: 0px; padding: 0px;\" \/>\u00a0 \u00a0 \u00a0DoCmd.TransferSpreadsheet acLink, acSpreadsheetTypeExcel8, Tabellenname, PfadZurExceldatei, True, Tabellenblatt<br style=\"margin: 0px; padding: 0px;\" \/>\u00a0 \u00a0 \u00a0Set db = Nothing<br style=\"margin: 0px; padding: 0px;\" \/>End Sub<\/code><\/dd>\n<\/dl>\n<p><br style=\"font: 12px\/16.79px Helvetica, Arial, sans-serif; margin: 0px; padding: 0px; color: #333333; text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: #ffffff; -webkit-text-stroke-width: 0px;\" \/><br style=\"font: 12px\/16.79px Helvetica, Arial, sans-serif; margin: 0px; padding: 0px; color: #333333; text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: #ffffff; -webkit-text-stroke-width: 0px;\" \/>Und schon geht&#8217;s!!!<\/p>\n<div class=\"pntrst_main_before_after\"><\/div><div class=\"fcbkbttn_buttons_block\" id=\"fcbkbttn_left\"><div class=\"fcbkbttn_like \"><fb:like href=\"https:\/\/tech-tipps.de\/?p=67\" action=\"like\" colorscheme=\"light\" layout=\"standard\"  width=\"450px\" size=\"small\"><\/fb:like><\/div><div class=\"fb-share-button  \" data-href=\"https:\/\/tech-tipps.de\/?p=67\" data-type=\"button_count\" data-size=\"small\"><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Problem: Ich habe als FE eine Access2007 ACCDB und als BE eine SQL2005-Datenbank. In meiner FE habe ich ebenfalls eine Excel-Datei verkn\u00fcpft. Aus dieser werden Auftragsdaten, die vom Kunden kommen in die SQL-Datenbank importiert. Da, sich nun der Speicherort und der Dateiname der Excel-Datei \u00e4ndern k\u00f6nnen, muss der Anwender die M\u00f6glichkeit haben, die Excel-Datei neu &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/tech-tipps.de\/?p=67\" class=\"more-link\"><span class=\"screen-reader-text\">\u201eExcel-Datei in Access2007 neu einbinden per VBA\u201c <\/span>weiterlesen<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,7,10],"tags":[63,101],"class_list":["post-67","post","type-post","status-publish","format-standard","hentry","category-datenbank","category-microsoft-office","category-programmierung","tag-excel","tag-microsoft-office"],"_links":{"self":[{"href":"https:\/\/tech-tipps.de\/index.php?rest_route=\/wp\/v2\/posts\/67","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tech-tipps.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech-tipps.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech-tipps.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tech-tipps.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=67"}],"version-history":[{"count":0,"href":"https:\/\/tech-tipps.de\/index.php?rest_route=\/wp\/v2\/posts\/67\/revisions"}],"wp:attachment":[{"href":"https:\/\/tech-tipps.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=67"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech-tipps.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=67"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech-tipps.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=67"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}