Title Block Info from Excel Sheet

Title Block Info from Excel Sheet

Anonymous
Not applicable
2,421 Views
5 Replies
Message 1 of 6

Title Block Info from Excel Sheet

Anonymous
Not applicable
I've created a custom title block. I'd like to use VB to fill in this title block using info obtained from an Excel Spreadsheet; Company Name, Location, Drawing Title, etc.
I don't know VB well enough to apply what I've read in other posts. I would think someone has done something similar.
Any help would be appreciated.
Jim
0 Likes
2,422 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
I am trying to accomplish the same thing...
0 Likes
Message 3 of 6

Anonymous
Not applicable
This is what I ended up with.

'Opens Excel File
Dim oXls As New Excel.Application
Set oXls = CreateObject("Excel.Application")
Dim oSheet As Excel.WorkSheet
Set oSheet = oXls.Workbooks.Open(oFileDlg.FileName).Sheets("sheet1")

'This will open your drawing file or you can omit if drawing is already open.
'Opens Drawing File
Dim oDoc As Document
Set oDoc = ThisApplication.Documents.Open(oFileDlg2.FileName)

'Sets a reference to the drawing document.
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument

'Drawing file is open, Sheet 1 is Active
'Set a reference to Titleblock

Dim oTitleBlockDefinition As TitleBlockDefinition
Dim oTextBox As TextBox
Dim strName As String
Set oTitleBlockDefinition = oDrawDoc.Sheets(1).TitleBlock.Definition
For Each oTextBox In oTitleBlockDefinition.Sketch.TextBoxes
strName = oTextBox.FormattedText

'Searches through all TextBoxes in Titleblock
'If TextBox Name is "....", change text to what's found in appropriate cell

If strName Like "*DRAWING NUMBER*" Then
oDrawDoc.Sheets(1).TitleBlock.SetPromptResultText oTextBox, oSheet.Range("E21")
End If

Obviously your title block has to contain Text Boxes for what you want to fill in for this to work.
Hope this helps.
0 Likes
Message 4 of 6

Anonymous
Not applicable

Hi, I am quite new to VBA and I'm looking to do the same thing (use excel to populate the titleblock). Thanks for the code 🙂  When I try to run this code I am getting an error:

 

"User-defined type not defined"

 

in reference to:

 

"Dim oXls As New Excel.Application" and "Dim oSheet As Excel.Application"

 

I'm guessing that it is not recognising Excel.application as a data type.

 

Everything I have looked up on the net seems to call up Excel in exactly this way, but it doesnt seem to work for me.

What screamingly obvious thing am I missing here?

 

Any help would be greatly appreciated

 

Thanks

 

Dion

Inventor 2011

Vista64

Office2007

 

 

0 Likes
Message 5 of 6

Anonymous
Not applicable

Solved it myself, guess I should have waited a little longer before posting Smiley Very Happy

 

Added reference from tools - reference

 

thanks

0 Likes
Message 6 of 6

Anonymous
Not applicable

I think we are looking for also but you are way over my head with it. What I am looking for is something to change the existing field in the iprop project tab for the .ipt which is linked to each sheet. (9088) to (9088A). We are using Inventor 2012 any help or direction would be a great help. I don't want to change the iprop for each .ipt we have a detail sheet for that would take some time for our large projects.

iprop.JPG

 

pro.JPG

Thank you

TLP

0 Likes