how new th file and open it.

how new th file and open it.

Anonymous
Not applicable
236 Views
1 Reply
Message 1 of 2

how new th file and open it.

Anonymous
Not applicable
How to new file in user input “new”,and opened this file.
What event?or make there?

This section of code below ,it can't Application.DocumentManager.Open. If opening will make a mistake.

private void OnDocumentCreated( object sender, DocumentCollectionEventArgs e )
{
if (!e.Document.Name.ToUpper().Contains("\\"))
{
string DOCNO = "";
DOCNO = new VPGetNO().GetVPDMDocNo(Command.DBName, Command.loginID, Command.loginPwd);
string secFildeName = ".dwg";
string FilePath = "C:\\";
if (DOCNO != "")
{
Database db = new Database();
db.SaveAs(FilePath + DOCNO, DwgVersion.Newest);
db.Dispose();
Document doc = Application.DocumentManager.Open(FilePath + DOCNO + secFildeName, false);
//Application.DocumentManager.MdiActiveDocument = doc;
}
}
}
This section of code below , it can Application.DocumentManager.Open(FilePath + DOCNO + secFildeName, false);
But “new” at new file,it’s not working.

Document doc = Application.DocumentManager.MdiActiveDocument;
doc.CommandEnded += new CommandEventHandler(cmdEnded);
public void cmdEnded(object o, CommandEventArgs e)
{
if (e.GlobalCommandName.ToUpper().Contains("NEW"))
{
string DOCNO = "";
DOCNO = new VPGetNO().GetVPDMDocNo(Command.DBName, Command.loginID, Command.loginPwd);
string secFildeName = ".dwg";
string FilePath = "C:\\";
if (DOCNO != "")
{
Database db = new Database();
db.SaveAs(FilePath + DOCNO, DwgVersion.Newest);
db.Dispose();

Document doc = Application.DocumentManager.Open(FilePath + DOCNO + secFildeName, false);
//Application.DocumentManager.MdiActiveDocument = doc;
}
}
}

Best Regards
0 Likes
237 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
use event DocumentCreated

e.Document.Database.SaveAs(PahtFileName, DwgVersion.Newest);

thks.
question is solve.
0 Likes