Macro no longer working with SW 2017

Hello people,

That is my problem. I have a macro that allows you to rename the drawing sheets by the name of the config inserted in this sheet. Until the 2016 version, it worked very well. I just upgraded to 2017 SP4.1 and it doesn't work properly anymore. It only changes the name of the 1st sheet.

And since I don't know anything about VB, I'm in a mess ...

Here is the file ...

Thank you in advance

Cala


config_to_sheet.swp

Hello 

Does Solid tell you an error or does the code compile but don't do what you want with it?

 

Dimitri

He does not give any errors.

The code runs as usual, it changes the name of the 1st sheet, moves on to the next sheets but does not change the name. He leaves the name already present.

Hello

 

After testing under SW2016 it already doesn't work very well because

No control of previous sheet name so that if the configuration has the same name, SW cannot rename multiple sheets with the same name

3 Likes

Did you write it or did you record it with the Macro recorder?

Is it possible to have configs with the same name in the same room? I don't think so.

For my use, it has always worked very well... until SW 2017

Neither written nor recorded there. I don't know anything about VB. It's a file that was given to me years ago.

But I don't know where it comes from.

In theory no it's not possible but on the other hand in your drawing it is possible that the reference view always uses the same configuration

 

The tracks are as follows

SetupSheet5 is outdated so already update it :)

http://help.solidworks.com/2017/english/api/sldworksapi/solidworks.interop.sldworks~solidworks.interop.sldworks.idrawingdoc~setupsheet5.html

2 Likes

Indeed I could use the same config in several sheets.

But in this case, I'm not using this macro.

It is used for my operations plans

Hello

Just to be sure, you have a room with x configurations, and the x configurations have them MEP in a single MEP file with a folio configuration?

1 Like

Correct!

Hello

You can start by replacing the line:

swSheet.SetName ConfigName

By:

swSheet.SetName ConfigName & "-" & i

Your sheets will then be named "ConfigName"-"SheetName", it's up to you to see if this is annoying.

Kind regards

Thanks for the info, but I don't need it.

You're welcome, and oops, sorry!

if it's an old macro 

see if it's not the iff and if that differ according to the versions

of solidworks and excel

and excel solidworks compatibility depending on the version too

@+ ;-)

Good evening

I agree with gt22 but the easiest way would be to scroll the macro in step-by-step to see the behavior and add debug.print to check the contents of configname.

In addition, it would have been good to "zap" the basemap, scan only the views and stop processing once a value has been obtained on the configuration.

I confirm on the other hand that it works on 2016 without problem (even if not very clean in terms of code) and that in any theory Solidworks does not have fun removing the so-called obsolete functions so probable bug elsewhere or hardware/software incompatibility.

1 Like

@gt22 & Cyril.f

Hola, I'm dumped. I do not understand what you are talking about at all.

Can anyone fix this macro to work on SW17?

Here is the contents of the .swp file

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swSheet As SldWorks.Sheet
Dim swModelview2 As Configuration
Dim vSheets As Variant
Dim swView As SldWorks.View
Dim Part As Object
Dim i As Integer

Sub main()

'The template is located in the SW template drawing folder

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDraw = swModel
Dim ConfigName As String
Dim bRet As Boolean
Dim vSheetProps As Variant


vSheets = swDraw.GetSheetNames
For i = 1 TB swDraw.GetSheetCount
swDraw.ActivateSheet vSheets(i - 1)
Set swSheet = swDraw.GetCurrentSheet

Count = swDraw.GetModelViewCount

Set swView = swDraw.GetFirstView

Do While Not swView Is Nothing
ConfigName = swView.ReferencedConfiguration
Set swView = swView.GetNextView
Loop
Set Part = swApp.ActiveDoc
boolstatus = Part.SetupSheet5(swSheet.GetName, 12, 12, 2, 3, True, "a3 - iso - NND.slddrt", 0.42, 0.297, "Default", True)
swSheet.SetName ConfigName

Next i

swModel.ForceRebuild3 (False)
End Sub
 

Hello

If you want you can try this one.

Kind regards


config_to_sheet_2.swp
3 Likes

Yes, it works. Result in pictures.

Thank you very much d.roger !!!!!!!!!!!

Have a good weekend.


macro_config_to_sheet_sw_2017.jpg