In your macro, you open Excel but you don't send it anything. You also have to create a binder, a sheet and fill in the cells. The debug.prints are only used to display the result in the VB output window. Here is the same macro but with a result that is displayed in excel.
For example, you can add a text at the bottom of the call number if it is not already in use. To try, you can add the line swDispDim.SetText swDimensionTextCalloutBelow, "(Ref A" & counter & ")" just before the line . Range("A" & counter). Value = "Reference below : " & swDispDim.GetText(swDimensionTextCalloutBelow)
First of all, I would like to point out that I know absolutely nothing about macro!
I dig up an old subject. I would like to make control sheets for the workshop. I found this post with a macro text. I copy paste and surprise it doesn't work. What for? if someone will give me his time to elucidate this mystery.
You need to add the reference to Microsoft Excel in your macro, for this you go to Tools / References... and you add Microsoft Excel xx.x Object Library:
With your help I have made good progress on the subject of control sheets. but I would like to go even further with the macro. I explain when executing the macro it opens any excel file but is it possible to make it open a pre-filled excel file that would contain a macro.
FYI we can do something quite close to what you want to do with the "tolerance table" utility of MyCADTools I have the impression (creation of a table retrieving the dimensions + location of them)
Here is the macro as well as the Excel file to make the control sheet. There's just a bug if on the plan there is an angel rating there it screws up.
Otherwise it's simple on the plan in order to limit the sorting of the dimensions you have to put first only the dimensions to be checked then run the macro, on the excel file that is opened click on the button and in the second tab is the control sheet. If anyone has another idea to customize it, let go.
PS: in the macro remember to change the path to the Excel file
So yes it works unless the dimension is an angle which is normal because in your macro on Excel you have the line "Temp = Replace(Split(Temp, "(")(1), "mm)", "")" which allows you to rework a value retrieved from the sheet created automatically from the SW macro but this value is not on the same writing format as for the other sides what we see in the lines:
If swDispDim.GetType = 3 Then . Range("A" & counter). Value = "Value : " & swDimension.GetSystemValue2("") * 180 / pi & Chr(176) Else . Range("A" & counter). Value = "Value: " & swDimension.GetSystemValue2("") * 1000 / 25.4 & """" & " (" & swDimension.GetSystemValue2("") * 1000 & "mm)" End If
of the SW macro.
These lines are just a formatting style of writing the dimension value for the Excel file and this can be changed easily as needed.
I have a hard time understanding why you go through a macro in your Excel file, everything you do in it can easily be done in the SW macro.
For my part, I would have tended to create a standard form in Excel and then fill it in from the SW macro, which avoids having to authorize macros in Excel and which also allows the reading of this file on LibreOffice for example.
The rows to be reworked in the SW macro are those between the "With sht" and "End With" lines to display only the values that are deemed necessary and send them to the desired Excel cells. A small example will surely follow in the coming days (or hours) following my availability.
Here is the small example as previously announced. You just have to change the path of the Excel file in the macro but leaving the file name as it is and then launch it from SW with a loaded plan.
You're a champion, my champion. Well, as said above, I don't have any knowledge of VBA, so I tinker, I tinker.
The Macor works well but curiously I have to run it 2 times. The first time she bellows at the first odds. I close Excel, I have an error 1004 I answer "end" I restart the macro and the miracle it works perfectly.
"Otherwise it's simple on the map in order to limit the sorting of the dimensions you have to put first only the dimensions to be checked then run the macro, on the Excel file that is open click on the button and in the second tab is the control sheet. If anyone has another idea to customize it, let it go."
What do you mean by putting first?
Since I have a drawing with about 100 sides and I only want 5 sides in my control panel