Hi all,
Currently, I am getting the inputs from the client in the excel format ( attached).I will have to measure each distance from a reference point and individually place the info along the linestring.I want to speed up this task by linking the distance column and ref.text column in the excel .
Please see the attached files. This example MVBA macro i have attached helps to place a text and marker at the user specified distance through userform .Now I want to link it to an excel and get the distances read from EXCEL/CSV .In the sample excel , there are 2 columns which I have marked in yellow(see PNG attached)
I will manually pick on the reference point(start point) on a linestring and all the asset info (i.e.., text & marker) should be placed along line automatically reading distances from excel.Please note that all the asset distances are from the start point.
I will be grateful if someone help me on this.
thanks.
-Josie
Hi Josie,
If I understand your question correctly, I think your difficulty is how to read Excel data from MVBA. Do you have the book "Learning MicroStation VBA" written by Jerry Winters ? In this book, there is a chapter named "Working With Excel". It tells you three ways to connect to Excel and read data from it.
HTH, Yongan
hi Yogan,
I don't have the book now.Can you please post any 1 such example of reading the distance from excel column.
thanks
Unknown said:I don't have the book now
This is the book that Yongan mentioned: Learning MicroStation VBA
Regards, Jon Summers LA Solutions
Been awhile since I've used vba since I switch to .NET addins but below should work.
BTW, if you are going to be doing VBA for MicroStation I would highly recommend Jerry Winters book that everyone is recommending.
First thing you'll need to do is create a reference to Excel within your mvba project. From the vba editor menu select Tools>References then from the select "Microsoft Excel XX.X Object Library". The XX.X is the version of Excel installed on your machine.
In your code to read from excel you can use:
Set xlApp = CreateObject("excel.application")
xlApp.Application.Visible = False 'false will keep the user from seeing the Excel application window
xlApp.Workbooks.Open "Sample-Assets.xls"
Set sheetA = xlApp.ActiveWorkbook.Worksheets("Sheet1")
dim distance as double
'you'll need to loop through the rows reading the data until no distance is encountered
dim i as integer
i = 2 'ignore the top row of your data since it is a header row
do while sheetA.Range("F" & i.tostring) <> ""
distance = sheetA.Range("F" & CStr(i))
' do your processing here
Loop
'end loop
Very kind of you Michael ! I will try this.
cheers!
Unknown said:Can you please post any example?
This article about MicroStation VBA and Excel may help.