Grasshopper

algorithmic modeling for Rhino

All,

I'm pretty new to scripting in VB.net, and this is pretty basic, but I'm missing a small tidbit that I need some help with.  I have a certain vb.net component that currently opens an excel file and then writes some data to a certain range of cells, but currently I am missing the small bit of code to save the file and then close that certain excel workbook.  One other thing to note is that I'm writing into another excel file concurrently from another set of VB componenets, which must remain open, so I don't want to save & close that file. - Only the file which I'm writing data to from this VB component needs to be saved & closed.  Any help would be appreciated.

 

Here is the current bit of code:

Rhino.Runtime.HostUtils.DisplayOleAlerts(False)
If _write = True Then
'Dim val As Double
Dim row As Integer
Dim column As Integer
Dim Pole As String
Dim Angle As Double
Dim cellValue As String
Dim rowstart As Integer

Dim xlApp As Object
xlApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application")
Dim wb As Object = xlApp.Workbooks.Open("W:\Bay Bridge Aiming\Knuckle Plate Aiming\Re-work_Field-Aim_20m.xlsx")
Dim sheet As Object = wb.Worksheets("Factory-Aim")

rowstart = 0

Do
rowstart += 1
cellValue = sheet.cells(rowstart, 1).value
Loop Until cellValue = ""

row = rowstart
column = 1
For Each Pole In Pole_ID
sheet.Cells(row, column).value = Pole
row = row + 1
Next

row = rowstart
column = 2
For Each Angle In KnucklePlt_Angle
sheet.Cells(row, column).value = Angle
row = row + 1
Next

End If
A = 0

 

Much thanks,

Joel

Views: 930

Attachments:

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2025   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service