dnenad Posted Sunday at 01:13 PM Posted Sunday at 01:13 PM This macro works in Solidworks 2024. Would someone please help me to get it working properly for 2025? See attached file. Thanks. jn_2.txt Quote
SLW210 Posted 23 hours ago Posted 23 hours ago What is the error you get? SolidWorks changed a few VBA commands from 2024 to 2025, you'll probably get better results on a SolidWorks/Dassault Systems forum. A quick search on SolidWorks VBA changes between 2024 and 2025 might help. Quote
mhupp Posted 18 hours ago Posted 18 hours ago (edited) You can wrap the inputbox with ucase(trim( or even add things infront like i did with description eliminating lines of code. old ' --- Ask user if they want to Add or Remove description --- action = InputBox("Type 'A' to Add description or 'R' to Remove description:", "Action Choice", "A") action = UCase(Trim(action)) If action <> "A" And action <> "R" Then MsgBox "Invalid input.": Exit Sub ' --- Optional prefix --- prefix = "" Dim userInput As String userInput = InputBox("Enter component location prefix: T for Top, B for Bottom, leave blank for none:", "Prefix Option") userInput = UCase(Trim(userInput)) If userInput = "T" Then prefix = "Top_" If userInput = "B" Then prefix = "Bot_" ' --- Optional description (only if adding) --- If action = "A" Then description = InputBox("Enter description to append (leave blank for none):", "Optional Description") description = Trim(description) If description <> "" Then description = "_" & description If description <> "" Then CopyToClipboardAPI (description) MsgBox "Description '" & description & "' copied to clipboard." End If End If New ' --- Ask user if they want to Add or Remove description --- action = UCase(Trim(InputBox("Type 'A' to Add description or 'R' to Remove description:", "Action Choice", "A"))) If action <> "A" And action <> "R" Then MsgBox "Invalid input.": Exit Sub ' --- Optional prefix --- Dim userInput As String userInput = UCase(Trim(InputBox("Enter component location prefix: T for Top, B for Bottom, leave blank for none:", "Prefix Option"))) Select Case True Case userInput = "T" prefix = "Top_" Case userInput = "B" prefix = "Bot_" Case Else prefix = "" End Select ' --- Optional description (only if adding) --- If action = "A" Then description = "_" & Trim(InputBox("Enter description to append (leave blank for none):", "Optional Description")) If description <> "_" Then ;old code would still allow "_" to be copied to clipboard this skips and should prob exit sub if description is only "_" ? CopyToClipboardAPI (description) MsgBox "Description '" & description & "' copied to clipboard." Else MsgBox "Description is Blank " & vbCrLf & " Exiting Command" Exit Sub End If End If Didn't run past fso. please describe what your running into. Edited 18 hours ago by mhupp Quote
BIGAL Posted 15 hours ago Posted 15 hours ago I only dabble in VBA but have these changed "kernel32" "user32" or maybe where you point to them, have had some VBA do this that refers to wrong library used. Quote
mhupp Posted 1 hour ago Posted 1 hour ago (edited) Also noticed the CopyToClipboardAPI can be replaced with three lines if you add a reference to Microsoft Forms 2.0 Object Library Dim obj As New MSForms.DataObject ... If description <> "_" Then obj.SetText description obj.PutInClipboard MsgBox "Description '" & description & "' copied to clipboard." Else Edited 1 hour ago by mhupp Quote
mhupp Posted 1 hour ago Posted 1 hour ago (edited) 14 hours ago, BIGAL said: I only dabble in VBA but have these changed "kernel32" "user32" or maybe where you point to them, have had some VBA do this that refers to wrong library used. Yea with the resent forced update in windows 11 some things went funky for people. Edited 59 minutes ago by mhupp Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.