Macro: The name of the sheet in a drawing

Does anyone have a SolidWorks macro (SW2014) to do this:

In a drawing, name (or rename) the first sheet "Plan"

What does the Macro recorder give you?

I haven't tested...

The following statement must be used:

swSheet.SetName "Plan"

2 Likes

Here's a macro to test:

http://www.lynkoa.com/tutos/macro-solidworks-renommer-feuille-1-de-la-msie-en-plan

 

1 Like

It remains to be sure that it will be the first.

Do you see launching the macro using a button?

[Edit] @.PL. Please, can you post your code on the post?

2 Likes

From the macro of @.PL here's what we did with it:

Sub lecture_seule_bib()
Dim swApp As Object
Dim Part As Object

'Information: I commented on each line of code directly from below it.
'If you have any questions, please feel free to come to http://www.lynkoa.com/user/register/uref/MTM0

title = "SOLIDWORKS FILE READ/WRITE MODE"
Set swApp = Application.SldWorks
    SolidWorks Application Declaration
Set Part = swApp.ActiveDoc
    Statement of the play
PathName = UCase(Part.GetPathName)
    Obtaining the path + filename
'If Left(UCase(PathName), 1) <> "O" Then
    The previous statement commented out, to use it, remove the ' (apostrophe) at the beginning of the line
    'In our company all library files are on O: (network drive)
    'IF: we check if the file is on O
    'ret = MsgBox("This file is not on O:, procedure aborted", , title)
    The previous statement commented out, to use it, remove the ' (apostrophe) at the beginning of the line
    'Message to indicate that the procedure is aborted because the file is not in our library
   ' Exit Sub
    The previous statement commented out, to use it, remove the ' (apostrophe) at the beginning of the line
    'End of the program if path different from O:
'End If
The previous statement commented out, to use it, remove the ' (apostrophe) at the beginning of the line
End of SI (IF) block

If GetAttr(PathName) And vbReadOnly Then
If the file is read-only
        ret = MsgBox("This file is read-only, do you want to write to it?" & vbNewLine_
        & vbNewLine & "Remember to save your changes later", vbYesNo, title)
        'message to ask if we want to access it in read and write
        If ret = vbNo Then Exit Sub
        'If not, we leave the programme
        SetAttr PathName, vbNormal
        'If so, we remove the read-only in Windows
        Part.FileReload
        ret = Part.ReloadOrReplace(False, Part.GetPathName, True)
        Part.FileReload
        'We reload the document in SolidWorks
Else
'Otherwise (= file read, write)
        ret = MsgBox("This file is read/write, do you want to make it read-only?", vbYesNo, title)
        'Message to ask if you want to access it in read-only mode
        If ret = vbNo Then Exit Sub
        'If not, we leave the programme
        SetAttr PathName, vbReadOnly
        'If so, we put read-only in Windows
        Part.FileReload
        ret = Part.ReloadOrReplace(False, Part.GetPathName, True)
        Part.FileReload
        'We reload the document in SolidWorks
End If
End Sub
End of the program: if you enjoyed it, please rate this tutorial on Lynkoa!

 


ficap_macro_renommer_premiere_feuille_mep.swp
1 Like