Great Code - Thank you @Cadline. Now I need it to work with Vault!

Great Code - Thank you @Cadline. Now I need it to work with Vault!

tracey_prior8CZVC
Explorer Explorer
398 Views
4 Replies
Message 1 of 5

Great Code - Thank you @Cadline. Now I need it to work with Vault!

tracey_prior8CZVC
Explorer
Explorer

I tweaked a Cadline Code and created an external rule and a global form (shown here).  From Inventor, it Checks if a document exists and if not creates it or opens it. (a word template), autofill's Name and Description. and gives it the same name as the cad file and saves it into the same folder.  ( I may have to change that but that's for another day.)

This is all on my local drives.  I will now get it saved into the company vault, ext rules area.  I also need to save the template in the vault templates file.  I am wondering how (I have replaced the path with xxx for this forum - confidentiality and all that.) I point to the template in vault.  Not done this before.  And have the subsequent word doc which is created in my local, be checked in to vault.  

tracey_prior8CZVC_0-1715938798055.png

 

'Code orginally Cadline Code - modified.
'set the folder name from the template report 
folder = "xxx" 
'Create the Word Application Object 
wordApp = Interaction.CreateObject("Word.Application") 
'Add the template document to the Word Session 
wordDoc = wordApp.Documents.Add(folder & "ilogic_report_template.docx", Visible:= False) 
'Write to the Bookmarks in the template 
wordDoc.Bookmarks("FNAME").Range.Text = ThisDoc.FileName(False) 

'without extension 
wordDoc.Bookmarks("DESC").Range.Text = iProperties.Value("Project", "Description")
'wordDoc.Bookmarks("PNUM").Range.Text = iProperties.Value("Project", "Part Number") 
'wordDoc.Bookmarks("DES").Range.Text = iProperties.Value("Summary","Author") 
'wordDoc.Bookmarks("RNUM").Range.Text = iProperties.Value("Project","Revision Number") 

'save iso view to jpg 
imagedoc = ThisDoc.PathAndFileName(False) & ".jpg" 
oCamera = InventorVb.Application.ActiveView.Camera 
'current iso view oCamera.fit oCamera.apply 
InventorVb.Application.ActiveView.SaveAsBitmap(imagedoc,1200,800)  
'Insert an image at the end of the document 
wordDoc.Bookmarks.Item("\endofdoc").Range.InlineShapes.AddPicture(imagedoc) 
'Save the Word file with a new name and close the document 
wordDoc.SaveAs(ThisDoc.PathAndFileName(False) & ".docx") 
wordDoc.Close() 
wordDoc = Nothing 
'Quit Word session 
wordApp.Application.Quit()  
wordApp = Nothing 
'Message box prompt – Added by Clint Brown @ Cadline 
i = MessageBox.Show("Would you like to see the Report?", "Cadline Community",MessageBoxButtons.YesNo,MessageBoxIcon.Question) 
If i = vbYes Then ThisDoc.Launch(ThisDoc.PathAndFileName(False) & ".docx") 

 

0 Likes
Accepted solutions (1)
399 Views
4 Replies
Replies (4)
Message 2 of 5

tracey_prior8CZVC
Explorer
Explorer

Also, \iLogic\UI\ Design Data is where Global forms are stored.  I think mine is local.  If that folder is placed in vault would all machines have to download it?  Seems like an issue for the tech guys.

0 Likes
Message 3 of 5

tracey_prior8CZVC
Explorer
Explorer

I forgot to mention for anyone wanting to use the code - The template that you create in word needs to have bookmarks added so the code can place the info in the word doc.  So for this line: 

'wordDoc.Bookmarks("PNUM").Range.Text = iProperties.Value("Project", "Part Number") 

PNUM is the bookmark name in word. 

0 Likes
Message 4 of 5

Frederick_Law
Mentor
Mentor
Accepted solution

Everything need to check in to Vault and everyone need to "get" them.

They should be under "Vault Workspace".

They should not expire and delete from local.

0 Likes
Message 5 of 5

tracey_prior8CZVC
Explorer
Explorer
Many thanks
0 Likes