<?xml version="1.0" encoding="iso-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="https://syndication.webwiz.net/rss_namespace/">
 <channel>
  <title>Dansk Regneark Forum : Undgå &quot;file in use message&quot;</title>
  <link>https://forum.excel-regneark.dk/</link>
  <description><![CDATA[Dette er et XML Feed af; Dansk Regneark Forum : Makro og VBA : Undgå &quot;file in use message&quot;]]></description>
  <pubDate>Sat, 05 Dec 2026 08:18:58 +0000</pubDate>
  <lastBuildDate>Tue, 15 Nov 2022 13:24:55 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 12.08</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>https://forum.excel-regneark.dk/RSS_post_feed.asp?TID=4816</WebWizForums:feedURL>
  <image>
   <title><![CDATA[Dansk Regneark Forum]]></title>
   <url>https://forum.excel-regneark.dk/css_styles/Excel-regneark.dk/logo.png</url>
   <link>https://forum.excel-regneark.dk/</link>
  </image>
  <item>
   <title><![CDATA[Undgå &quot;file in use message&quot; : Jeg har en makro som opdaterer...]]></title>
   <link>https://forum.excel-regneark.dk/undga-file-in-use-message_topic4816_post23782.html#23782</link>
   <description>
    <![CDATA[<strong>Forfatter:</strong> <a href="https://forum.excel-regneark.dk/member_profile.asp?PF=2001">P.K..</a><br /><strong>Emne:</strong> 4816<br /><strong>Sendt:</strong> 15.Nov.2022 kl. 13:24<br /><br />Jeg har en makro som opdaterer en række regnearks i et givent directory.&nbsp; Problemet er at andre brugere også kan have regnearket åbent (eller der kan være gået nået galt i lukningen så det systemmæssigt på serveren er "optaget af anden bruger") når min makro kører - og i så tilfælde skal det konkrete regneark bare springes over til næste gang makroen kører.<div><br></div><div>Det lykkes nogle gange - og andre gange kommer der en prompt op om hvorvidt regnearket skal åbnes for readonly eller ej - og min makro går i stå.&nbsp; Jeg har forsøgt at komme af med den prompt utallige gange men den bliver ved med at komme i enkelte tilfælde.&nbsp;&nbsp;</div><div><br></div><div>Håber I eksperter kan se en fejl eller 2 i opbygningen af makroen:</div><div><br></div><div><div>Sub OpdaterFiler()</div><div>&nbsp; &nbsp; Application.ScreenUpdating = False</div><div>&nbsp; &nbsp; Application.Calculation = xlCalculationManual</div><div>&nbsp; &nbsp; Dim fil As String</div><div>&nbsp; &nbsp; Dim wkb As Workbook</div><div>&nbsp; &nbsp; Dim wkbCurrent As Workbook</div><div>&nbsp; &nbsp; Set wkbCurrent = ActiveWorkbook</div><div>&nbsp; &nbsp; Dim previousSecurity As MsoAutomationSecurity</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; 'Disable on_open</div><div>&nbsp; &nbsp; previousSecurity = Application.AutomationSecurity</div><div>&nbsp; &nbsp; Application.AutomationSecurity = msoAutomationSecurityForceDisable</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; fil = Dir(Names("Mappe2").RefersToRange.Value2 &amp; "\*.xlsm")</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; Do While fil &lt;&gt; ""</div><div>&nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; Set wkb = Workbooks.Open(Names("Mappe2").RefersToRange.Value2 &amp; "\" &amp; fil, False)</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; If wkb.Name &lt;&gt; wkbCurrent.Name And wkb.ReadOnly Then</div><div>&nbsp;<span style="white-space:pre">		</span> '&nbsp; &nbsp; &nbsp; MsgBox ("fil er allerede åben derfor ingen action")</div><div>&nbsp; &nbsp; &nbsp; &nbsp; wkb.Close SaveChanges:=False</div><div>&nbsp; &nbsp; &nbsp; &nbsp; Set wkb = Nothing</div><div>&nbsp; &nbsp; &nbsp; &nbsp;Else</div><div>&nbsp;<span style="white-space:pre">		</span>'&nbsp; &nbsp; &nbsp; &nbsp;MsgBox ("fil er åben for redigering")</div><div>&nbsp; &nbsp; &nbsp; &nbsp; 'Ikke skrivebeskyttet (åbnet af andre)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wkb.RefreshAll</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wkb.Worksheets("Overblik").Select</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wkb.Worksheets("Overblik").Unprotect</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wkb.Worksheets("Overblik").Range("b1").Value2 = "Fil opdateret"</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wkb.Worksheets("Overblik").Range("c1").Value2 = Now</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wkb.Save</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wkb.Close SaveChanges:=True</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set wkb = Nothing</div><div>&nbsp; &nbsp; &nbsp; &nbsp; End If</div><div>&nbsp; &nbsp; &nbsp; &nbsp; fil = Dir</div><div>&nbsp; &nbsp; Loop</div><div>&nbsp; &nbsp; 'slå til igen</div><div>&nbsp; &nbsp;<span style="white-space:pre">		</span> ' MsgBox ("makro er færdig")</div><div>&nbsp; &nbsp; Application.AutomationSecurity = previousSecurity</div><div>&nbsp; &nbsp; Application.DisplayAlerts = True</div><div>&nbsp; &nbsp; Application.ScreenUpdating = True</div><div>&nbsp; &nbsp; Application.Calculation = xlCalculationAutomatic</div><div>&nbsp; &nbsp;&nbsp;</div><div>End Sub</div></div>]]>
   </description>
   <pubDate>Tue, 15 Nov 2022 13:24:55 +0000</pubDate>
   <guid isPermaLink="true">https://forum.excel-regneark.dk/undga-file-in-use-message_topic4816_post23782.html#23782</guid>
  </item> 
 </channel>
</rss>