Inventor To Excel Cast Error

Inventor To Excel Cast Error

Anonymous
Not applicable
865 Views
7 Replies
Message 1 of 8

Inventor To Excel Cast Error

Anonymous
Not applicable

All,

 

I have this code:

 

Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 11711 StartFragment: 314 EndFragment: 11679 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet

Sub Main

     TOWER_ID = GoExcel.CellValue(EXCEL_LINK , "SUPPORT""tower_id_supt")
    SUPPORT_RING_WIDTH = GoExcel.CellValue(EXCEL_LINK , "SUPPORT""wid_supt_ring_supt")
    BEARING_BAR_HEIGHT = GoExcel.CellValue(EXCEL_LINK , "SUPPORT""ht_802_total_supt")
    BEARING_BAR = GoExcel.CellValue(EXCEL_LINK , "SUPPORT""matl_thk_bearing_bar_supt")
    BOLTING_BAR_CL = GoExcel.CellValue(EXCEL_LINK , "SUPPORT""bolt_bar_loc_supt")
    CLAMPING_REQUIRED = GoExcel.CellValue(EXCEL_LINK , "SUPPORT""clamping_supt")
    CLAMP_QTY = GoExcel.CellValue(EXCEL_LINK , "SUPPORT""qty_clamp_supt")
    
    
        MsgBox ("Tower I.D. = " & TOWER_ID & vbCrLf & 
                "Support Ring Width= " & SUPPORT_RING_WIDTH & vbCrLf &
                "Bearing Bar Height = " & BEARING_BAR_HEIGHT & vbCrLf &
                "Bearing Bar Thickness = " & BEARING_BAR & vbCrLf &
                "Bolting Plates ON/OFF CL = " & BOLTING_BAR_CL & vbCrLf &
                "Clamping Required = " & CLAMPING_REQUIRED & vbCrLf &
                "Clamp Quantity  = " & CLAMP_QTY)

iLogicVb.UpdateWhenDone = True


End Sub

 The EXCEL_LINK is based off of a parameter that is fed by a 3RD party program..... Now I am having this issue:

 

cast.PNGcast1.PNG

 

Which I can't find the issue... I've even called out TOWER_ID as a double, which then will read the number within the excel sheet but won't update the parameter...

 

Please help!! 

0 Likes
866 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable

The first thing I notice is that the Excel file isn't being opened.

Try 
	GoExcel.Open(FilePath, oSheet)
Catch
	MessageBox.Show("Error opening the Excel File")
	Return
End Try

I usually have this code to initialize, then you'll want to close it with a simple:

GoExcel.Close
0 Likes
Message 3 of 8

HermJan.Otterman
Advisor
Advisor

Hello Emiller,

 

what is the value of the "EXCEL_LINK"

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 4 of 8

Anonymous
Not applicable

The value of EXCEL_LINK is a file path that is already open and is specified by a 3rd party program. So it could be any value/file path. 

0 Likes
Message 5 of 8

HermJan.Otterman
Advisor
Advisor

can you share your excel file?

 

so with: GoExcel.CellValue(FullPath as string, Sheet name, Cell name)

 

so is "tower_id_supt" a cel name?? or a column header?

 

if it is the header of a column, you should first locate the right line with:

 

 

i = GoExcel.FindRow(EXCEL_LINK, "SUPPORT", "tower_id_supt", "=", 123)
SUPPORT_RING_WIDTH = GoExcel.CurrentRowValue("wid_supt_ring_supt")

 

and with the second line, get the value from a column

 

 

 

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 6 of 8

Anonymous
Not applicable

The "tower_id_supt" is a cel name. And the odd thing is that it will read the cell value. If I call out TOWER_ID as a Double, but it won't update the parameters.

0 Likes
Message 7 of 8

Anonymous
Not applicable

Also there are three other people running this code and it works for them and their models...

0 Likes
Message 8 of 8

HermJan.Otterman
Advisor
Advisor

can you share the excel file?

then I will have a look at it

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes