<?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: VBA -&amp;gt; VB.NET issues with SaveAs in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/vba-gt-vb-net-issues-with-saveas/m-p/2794470#M63539</link>
    <description>&lt;P&gt;Why not just use the window filesystem FILE.COPY&amp;nbsp;to make the new file (copy your prototype file to the desired location and rename)? Then open the new document and do your work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 12 Oct 2010 16:43:28 GMT</pubDate>
    <dc:creator>michael_robertson</dc:creator>
    <dc:date>2010-10-12T16:43:28Z</dc:date>
    <item>
      <title>VBA -&gt; VB.NET issues with SaveAs</title>
      <link>https://forums.autodesk.com/t5/net-forum/vba-gt-vb-net-issues-with-saveas/m-p/2794384#M63538</link>
      <description>Hi all,&lt;BR /&gt;I'm trying to do what I consider a simple task (at least it's simple in VBA, but I'm trying to move away from VBA since it's no longer supported): Create a new, blank DWG file, save it to a specified directory and have it become the active file inside the ACAD UI for further editing.&lt;BR /&gt;&lt;BR /&gt;I've been able to cobble together several variations of code that adds a new document to the UI, and even saves it out to the proper location'/filename, but even when it accomplishes this successfully, ACAD dies when I close it down with: "FATAL ERROR: Unhandled Access Violation Reading 0x0041 Exception at 3f892986h".&lt;BR /&gt;&lt;BR /&gt;For background, I'm running ACAD2011 (plain) on Windows 7, 64-bit. The code that I've used with best results is a brute-force, stuff-the-command-line setup as follows (with thanks to Kean Walmsley of "Through the Interface"):&lt;BR /&gt;&lt;BR /&gt;Imports Autodesk.AutoCAD.Interop&lt;BR /&gt;Imports Autodesk.AutoCAD.Interop.Common&lt;BR /&gt;Imports Autodesk.AutoCAD.ApplicationServices&lt;BR /&gt;Imports Autodesk.AutoCAD.Runtime&lt;BR /&gt;&lt;BR /&gt;&amp;lt;CommandMethod("bmiFileNew", CommandFlags.Modal)&amp;gt; _&lt;BR /&gt;Public Sub bmiFileNew()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim ufn As New ufFileNew&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim drResult As System.Windows.Forms.DialogResult&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim dwgActive As Document&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim sPrototypeDwg As String&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim sNewFilename As String&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim sLispCommand As String&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;NewFile = ""&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Try&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;drResult = Application.ShowModalDialog(ufn)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If NewFile &amp;lt;&amp;gt; "" Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sPrototypeDwg = "C:\TEMP\Template2011"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sNewFilename = "C:\TEMP\" &amp;amp; NewFile&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim acDocMgr As DocumentCollection = Application.DocumentManager&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dwgActive = acDocMgr.Add(sPrototypeDwg)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sNewFilename = Replace(sNewFilename, "\", "/")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim ocmd As Object = Application.GetSystemVariable("CMDECHO")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sLispCommand = "(setvar ""CMDECHO"" 1) " &amp;amp; _&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"(command ""_.SAVEAS"" ""2010"" """ &amp;amp; sNewFilename &amp;amp; """) " &amp;amp; _&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"(setvar ""CMDECHO"" " &amp;amp; ocmd.ToString &amp;amp; ") " &amp;amp; _&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"(princ) "&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dwgActive.SendStringToExecute(sLispCommand, _&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;True, _&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;False, _&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;True)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;acDocMgr.MdiActiveDocument = dwgActive&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End If&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Catch ex As Exception&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MsgBox(ex.Message.ToString)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;End Try&lt;BR /&gt;End Sub&lt;BR /&gt;&lt;BR /&gt;I've also tried using Database.Saveas() and Document.SaveAs() alternatives with less success than this and still I have the fatal error when exiting ACAD. Any assistance would be much appreciated.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Dave&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Oct 2010 15:32:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/vba-gt-vb-net-issues-with-saveas/m-p/2794384#M63538</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-10-12T15:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: VBA -&gt; VB.NET issues with SaveAs</title>
      <link>https://forums.autodesk.com/t5/net-forum/vba-gt-vb-net-issues-with-saveas/m-p/2794470#M63539</link>
      <description>&lt;P&gt;Why not just use the window filesystem FILE.COPY&amp;nbsp;to make the new file (copy your prototype file to the desired location and rename)? Then open the new document and do your work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2010 16:43:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/vba-gt-vb-net-issues-with-saveas/m-p/2794470#M63539</guid>
      <dc:creator>michael_robertson</dc:creator>
      <dc:date>2010-10-12T16:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: VBA -&gt; VB.NET issues with SaveAs</title>
      <link>https://forums.autodesk.com/t5/net-forum/vba-gt-vb-net-issues-with-saveas/m-p/2794640#M63540</link>
      <description>&lt;P&gt;Hi Michael,&lt;/P&gt;&lt;P&gt;Thanks for the response. &amp;nbsp;I suppose that is one alternative. &amp;nbsp;It just grinds me when I've got two simple lines of VBA code that I have to completely revamp to put into .NET.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, after letting ACAD send the error data back to AutoDesk, it informed me that a patch was available to help with this issue. &amp;nbsp;After downloading it and applying, it seems to have fixed the problem. &amp;nbsp;So now I have to go back thru the 5 different ways I've tried to solve this to find the "best" one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;Dave&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2010 18:14:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/vba-gt-vb-net-issues-with-saveas/m-p/2794640#M63540</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-10-12T18:14:39Z</dc:date>
    </item>
    <item>
      <title>Re: VBA -&gt; VB.NET issues with SaveAs</title>
      <link>https://forums.autodesk.com/t5/net-forum/vba-gt-vb-net-issues-with-saveas/m-p/2801478#M63541</link>
      <description>&lt;P&gt;I'm somewhat new to this myself, but&amp;nbsp;I just finished&amp;nbsp;converting one of my VBA programs.&amp;nbsp; The issue may be with the command flag settings.&amp;nbsp; Try this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1"&gt;&amp;lt;CommandMethod(&lt;FONT color="#a31515"&gt;&lt;FONT color="#a31515"&gt;"DrawingInUI"&lt;/FONT&gt;&lt;/FONT&gt;)&amp;gt; _&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" size="2"&gt;&lt;FONT color="#0000ff" size="2"&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1"&gt;Public &lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;Sub&lt;/FONT&gt;&lt;/FONT&gt; DrawingInUI()&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1"&gt;&lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt; MYDocMgr &lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;As&lt;/FONT&gt;&lt;/FONT&gt; DocumentCollection = Application.DocumentManager&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1"&gt;&lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt; MYDoc &lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;As&lt;/FONT&gt;&lt;/FONT&gt; Document&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1"&gt;&lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt; testDB &lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;As&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;New&lt;/FONT&gt;&lt;/FONT&gt; Database(&lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;False&lt;/FONT&gt;&lt;/FONT&gt;, &lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;True&lt;/FONT&gt;&lt;/FONT&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1"&gt;&lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt; fileName &lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;As&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;String&lt;/FONT&gt;&lt;/FONT&gt; = &lt;FONT color="#a31515"&gt;&lt;FONT color="#a31515"&gt;"Test"&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#008000"&gt;'new drawing name&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1"&gt;&lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt; MyPath = &lt;FONT color="#a31515"&gt;&lt;FONT color="#a31515"&gt;"c:\"&lt;/FONT&gt;&lt;/FONT&gt; &amp;amp; fileName &amp;amp; &lt;FONT color="#a31515"&gt;&lt;FONT color="#a31515"&gt;".dwg"&lt;/FONT&gt;&lt;/FONT&gt; 'Path to save new drawing to.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1"&gt;testDB.ReadDwgFile(&lt;FONT color="#a31515"&gt;&lt;FONT color="#a31515"&gt;"N:\ACAD\DWG\ENG-DWG\TITLE\AFE-TITLE-2.dwg"&lt;/FONT&gt;&lt;/FONT&gt;, FileOpenMode.OpenForReadAndAllShare, &lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;True&lt;/FONT&gt;&lt;/FONT&gt;, &lt;FONT color="#a31515"&gt;&lt;FONT color="#a31515"&gt;""&lt;/FONT&gt;&lt;/FONT&gt;) &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1"&gt;&lt;FONT color="#008000"&gt;&lt;FONT color="#008000"&gt;'Path of template file to open as a new drawing - in this case a drawing with a title block.&lt;/FONT&gt;&lt;/FONT&gt; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1"&gt;&lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;Try&lt;/FONT&gt;&lt;/FONT&gt; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1"&gt;testDB.SaveAs(MyPath, DwgVersion.Current) &lt;FONT color="#008000"&gt;&lt;FONT color="#008000"&gt;'Save the template drawing as a new drawing (without opening it up in the user interface)&lt;/FONT&gt;&lt;/FONT&gt; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1"&gt;testDB.Dispose()&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1"&gt;&lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;Catch&lt;/FONT&gt;&lt;/FONT&gt; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1"&gt;&lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;End&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;Try&lt;/FONT&gt;&lt;/FONT&gt; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1"&gt;MYDoc = MYDocMgr.Open(MyPath, &lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;False&lt;/FONT&gt;&lt;/FONT&gt;, &lt;FONT color="#a31515"&gt;&lt;FONT color="#a31515"&gt;""&lt;/FONT&gt;&lt;/FONT&gt;) &lt;FONT color="#008000"&gt;&lt;FONT color="#008000"&gt;' Open the newly created drawing up into the user interface.&lt;/FONT&gt;&lt;/FONT&gt; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1"&gt;DocumentManager.MdiActiveDocument = MYDoc&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1"&gt;&lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;End&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;Sub&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt;&lt;FONT size="2"&gt;&lt;FONT size="2"&gt;&lt;FONT size="2"&gt;&lt;FONT size="2"&gt;&lt;FONT size="2"&gt;&lt;FONT size="2"&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Oct 2010 21:49:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/vba-gt-vb-net-issues-with-saveas/m-p/2801478#M63541</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-10-19T21:49:27Z</dc:date>
    </item>
  </channel>
</rss>

