SaveCopyAs Error

SaveCopyAs Error

naresh_kalyan
Advocate Advocate
487 Views
5 Replies
Message 1 of 6

SaveCopyAs Error

naresh_kalyan
Advocate
Advocate
Hi all,
My code working everything fine except the line and I attached the Error Message also. Do the VB Application needs any Reference Components. Plz... Help me


For Each referencedDoc In allReferencedDocs
' Get the full filename of the current document.
designFilename = referencedDoc.FullFileName

' Replace instances of the old design name with the new name
'newDrawingFilename = Replace(COPIPATH & ".idw", Filnam, True)
designFilename = Replace(COPIPATH & ".idw", Filnam, Filnam)

' Add the current file to the FileSaveAs object.
fileSaveAs.AddFileToSave referencedDoc, designFilename
Next

' Do the save copy as of all the files.
fileSaveAs.ExecuteSaveCopyAs

' Close the drawing.
apprenticeServer.Close


MsgBox ("Finished copying design.")
Plz, find the attachment.

Thanks in Advance.
NKalyan
0 Likes
488 Views
5 Replies
Replies (5)
Message 2 of 6

naresh_kalyan
Advocate
Advocate
Dear all,
Here is the complete Code.
Please help me....

Public Sub Happydays()
PROJECT PARAMETERS 'GETTING ALL PARAMETERS FROM "ADODB"
Filnam = "ProjID" & lensiz & widsiz & thksiz
TEMP = App.Path & "\Temp\" & Filnam

DESPATH = BROWPATH & Filnam

Set fso = New FileSystemObject
fso.CopyFolder App.Path & "\PROJECT_FILES\ABA202030", TEMP, True

existingDesignName = "ABA202030"
newDesignName = Filnam

Set fso = New FileSystemObject
drawingFilenames = fso.GetFile(TEMP & "\ABA202030.idw")
Set apprenticeServer = New ApprenticeServerComponent

Set drawingDoc = apprenticeServer.Open(drawingFilenames)
Set fileSaveAs = apprenticeServer.fileSaveAs
newDrawingFilename = drawingDoc.FullFileName

newDrawingFilename = Replace(TEMP & ".idw", "ABA202030", Filnam)
fileSaveAs.AddFileToSave drawingDoc, Filnam
Set allReferencedDocs = drawingDoc.AllReferencedDocuments

For Each referencedDoc In allReferencedDocs
designFilename = referencedDoc.FullFileName
designFilename = Replace(TEMP & ".idw", "ABA202030", Filnam)
fileSaveAs.AddFileToSave referencedDoc, designFilename
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
fileSaveAs.ExecuteSaveCopyAs ' "ERROR IS AT THIS LINE" Please refer the attachment
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
apprenticeServer.Close
Next
MsgBox ("Finished copying design.")
End Sub
0 Likes
Message 3 of 6

Anonymous
Not applicable
Not quite sure what the problem is. But I see some issues in the code logic.
You are closing Apprentice server within the For...Next loop. I would
suggest that you change the logic to something along the following lines:

For Each referencedDoc In allReferencedDocs
designFilename = referencedDoc.FullFileName
designFilename = Replace(TEMP & ".idw", "ABA202030", Filnam)
fileSaveAs.AddFileToSave referencedDoc, designFilename
Next

fileSaveAs.ExecuteSaveCopyAs
apprenticeServer.Close

Sanjay-


wrote in message news:5525702@discussion.autodesk.com...
Dear all,
Here is the complete Code.
Please help me....

Public Sub Happydays()
PROJECT PARAMETERS 'GETTING ALL PARAMETERS FROM "ADODB"
Filnam = "ProjID" & lensiz & widsiz & thksiz
TEMP = App.Path & "\Temp\" & Filnam

DESPATH = BROWPATH & Filnam

Set fso = New FileSystemObject
fso.CopyFolder App.Path & "\PROJECT_FILES\ABA202030", TEMP, True

existingDesignName = "ABA202030"
newDesignName = Filnam

Set fso = New FileSystemObject
drawingFilenames = fso.GetFile(TEMP & "\ABA202030.idw")
Set apprenticeServer = New ApprenticeServerComponent

Set drawingDoc = apprenticeServer.Open(drawingFilenames)
Set fileSaveAs = apprenticeServer.fileSaveAs
newDrawingFilename = drawingDoc.FullFileName

newDrawingFilename = Replace(TEMP & ".idw", "ABA202030", Filnam)
fileSaveAs.AddFileToSave drawingDoc, Filnam
Set allReferencedDocs = drawingDoc.AllReferencedDocuments

For Each referencedDoc In allReferencedDocs
designFilename = referencedDoc.FullFileName
designFilename = Replace(TEMP & ".idw", "ABA202030", Filnam)
fileSaveAs.AddFileToSave referencedDoc, designFilename
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
fileSaveAs.ExecuteSaveCopyAs ' "ERROR IS AT THIS LINE" Please refer the
attachment
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
apprenticeServer.Close
Next
MsgBox ("Finished copying design.")
End Sub
0 Likes
Message 4 of 6

naresh_kalyan
Advocate
Advocate
Thanks for the response... but there's no change. Same Error. Once again I am typing the Error ..
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Run-time error '-2147467259(800004005)':
Method 'ExecuteSaveCopyAs' of object '_IRxFileSaveAs' failed
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Do I need to load any Add-inns or Components or References..
Please... Sanjay. Please help me out.

NKalyan
0 Likes
Message 5 of 6

naresh_kalyan
Advocate
Advocate
Dear Sanjay,
Thanks for ur support and I figured it out.
But, Here one more Error I am facing while running my EXE file. I have attached a jpeg file which shows the Error.
Is this a Virus or any system Problem?
Thanks again!!!

NKalyan
0 Likes
Message 6 of 6

Anonymous
Not applicable
there was an error thrown that wasn't handled, that is what the message is essentially saying.

Try replacing the section of code giving the error with:

On Error Resume Next
fileSaveAs .ExecuteSaveCopyAs
If Err Then
MsgBox Err.Description(), vbOK, "Error"
Err.Clear
End If
On Error Resume 0
0 Likes