Drawing Save Error

Discussion in 'AutoCAD' started by pkirill, Feb 17, 2004.

  1. pkirill

    pkirill Guest

    So I'm trying to use the following code to open one drawing, save it to
    another name, do some stuff, then close it with a save. But I keep getting
    "Error saving the document" at the dwg.close. I think it might have
    something to do with a fumbled pass defining 'dwg' then saving it as
    something else, but I don't know...

    If chkElExBs.Value = Checked Then
    Set dwg = acad.Documents.Open(EDSpath & "ELEC\Drawings\_n04EMB.dwg")
    dwg.SaveAs (EDSpath & "arch\colorsend\HCYU_ELEC_BSMT_EXIST_n04EMB.dwg"),
    ac2000_dwg
    cmdDetXref 'call sub to detach xrefs
    strClrCode = "1" 'set the layer color for ELEC
    cmdLayFix 'call sub to manipulate layers

    dwg.Close (True) ' this is where
    End If


    Any ideas?
     
    pkirill, Feb 17, 2004
    #1
  2. pkirill

    Eric Stewart Guest

    Do your subroutines save the drawing?

    Have you tried adding ThisDrawing.Save before dwg.Close?

    Seems too simple of an answer though. :|
     
    Eric Stewart, Feb 17, 2004
    #2
  3. pkirill

    pkirill Guest

    I did try the ThisDrawing.Save - all it does is move up my error. I really
    think it has something to do with setting DWG = Drawing1, then saving as
    Drawing2. Possibly a "save as" does not change the value of DWG from
    "Drawing1" to "Drawing2". I'm going to try a do a copy Drawing1, Rename
    Drawing1 to Drawing 2, then open Drawing2. We'll see if that works...
     
    pkirill, Feb 17, 2004
    #3
  4. Is the drawing you're openning a 2000 dwg version also ?
     
    Jorge Jimenez, Feb 17, 2004
    #4
  5. pkirill

    pkirill Guest

    The drawing I am opening is a 2000 format file created in 2004 (saved as
    2000 from AutoCAD). It may be possible that the file being opened is
    already opened by another user, but the SaveAs happens so fast I can't catch
    any (Read Only) messages. BUT that is, in part what the SaveAs was supposed
    to be for...

    As always, much thanks for any tips...
     
    pkirill, Feb 18, 2004
    #5
  6. Try adding a Set dwg = ActiveDocument before you close it and see if it
    helps
    ___________________________
    Mike Tuersley
    CADalyst's AutoCAD Clinic
    Rand IMAGINiT Technologies
     
    Mike Tuersley, Feb 18, 2004
    #6
  7. pkirill

    pkirill Guest

    Thanks for all the replies - but to no avail. Even if I leave the
    'dwg.SaveAs' drawings open, then try to close them manually, it tells me the
    drawing is write-protected. Argggh!
     
    pkirill, Feb 18, 2004
    #7
  8. pkirill

    pkirill Guest

    So this works:


    Dim FileCheck as New FileSystemObject
    Dim acad As New AcadApplication
    Dim dwg As AcadDocument
    FileCheck.CopyFile "H:\OldPath\Drawing1.dwg", "H:\NewPath\Drawing2.dwg",
    True 'Copy original to new location and new name, overwrite existing
    file
    Set dwg = acad.Documents.Open("H:\NewPath\Drawing2.dwg")
    'Open new file
    <unload xrefs, change layer colors, etc>
    'Do some stuff to the drawing
    dwg.close (true)
    'close it with a save

    The issue only came up when the original file was open for editing. By
    copying it first, no problem.

    Thanks again for all the help!
     
    pkirill, Feb 18, 2004
    #8
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.