9 Replies Latest reply on Nov 5, 2013 7:22 AM by Mubashir Tahir

    Cannot open Macros

    Mubashir Tahir

      Hello everyone.

       

      Hope someone of you experts can help me.

       

      I have written a macro to write the customproperties of every part in assembly in Excel sheet. It is a very long macros.

      I invest a lot of time. Because I am not an expert in writing macros.

       

      When I oppen it today to edit the macro, it crash. I can not open it.

       

      Can anyone of you open the macro and safe the code.

        • Re: Cannot open Macros
          Keith Rice

          Welcome to the forums.

           

          Many times it's not enough to just re-save the code on someone else's computer. They actually need to export the individual modules, then you can reimport them into a new macro on your computer. I've attached the exported modules.

           

          Keith

          SolidWorks API Tutorials

            • Re: Cannot open Macros
              Mubashir Tahir

              Hello Keith

               

              Thank You verry much. It works.

               

              You save me a lot of time.

              • Re: Cannot open Macros
                Deepak Gupta

                Keith out of curiosity I want to know if you opened/extracted the module via SolidWorks or some other software. If I try to open the original macro posted, I get the same error as Mubashir. Even same thing happens with me on some of my other macros. Any pointer/suggestions to retrieve the macros will be appreciated.

                • Re: Cannot open Macros
                  Mubashir Tahir

                  Hello Keith and all other helper

                   

                  I have again the same error and I can not oppen the macro.

                   

                  I can not understand how this can happen? Can you unpack the macro and send it back to me.

                  And can you tell me how you do that. It will be verry much appreciated.

                    • Re: Cannot open Macros
                      Laszlo Szucs

                      Hi Mubashir,

                      I could open your code in SW 2014. Here it is:

                       

                      Option Explicit

                          Dim lastRow             As Long

                          Dim lastColumn          As Long

                         

                          Dim FileCSV             As String

                       

                       

                      Public Sub PlexUploadList2()

                       

                       

                       

                       

                          xlSheet.Cells(1, 1) = "Tool No"

                          xlSheet.Cells(1, 2) = "Attribute"

                          xlSheet.Cells(1, 3) = "Attribute Value"

                          xlSheet.Cells(1, 4) = "Unit"

                         

                       

                       

                          For n = 0 To PartNumber - 1

                         

                             If Plex_Data(n).Part_Plexus = "Yes" Then

                            

                                 xlSheet.Cells(2 + n, 1) = ASM_Tool_No + "." + Plex_Data(n).Part_DetailNumber

                                 xlSheet.Cells(2 + n, 2) = "HRC"

                                 xlSheet.Cells(2 + n, 3) = Plex_Data(n).Part_HRC

                                

                             End If

                         

                          Next n

                       

                       

                          lastRow = xlSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row

                          lastColumn = 4 'xlSheet.Cells(lastRow, 256).End(xlToLeft).Column

                       

                       

                          With xlSheet.Sort

                              .SortFields.Clear

                              .SortFields.Add Key:=xlSheet.Range(xlSheet.Cells(2, 1), xlSheet.Cells(lastRow, 1)), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal

                              .SetRange xlSheet.Range("A1", xlSheet.Cells(lastRow, lastColumn))

                              .Header = xlYes

                              .MatchCase = False

                              .Orientation = xlTopToBottom

                              .SortMethod = xlPinYin

                              .Apply

                          End With

                       

                       

                          FileCSV = MyPath + "\" + ASM_Tool_No + " Tool Attribute" + ".csv"

                       

                       

                       

                       

                              On Error GoTo SafeError_1

                             

                                  If UserForm1.CheckBox6 = False Then xlBook.SaveAs FileCSV, FileFormat:=xlCSV, CreateBackup:=False

                                 

                              On Error GoTo 0

                             

                      SafeError_1:

                       

                       

                              If Err.Number = 1004 Then

                             

                                  On Error GoTo 0

                                 

                              End If

                             

                      End Sub