Hi all
After several unsuccessful attempts, I decided to come and get a little more help.
I need to retrieve the contents of a cell in an excel file and then define it as a file name.
The goal would therefore be:
-Recover the contents of the cell,
- Set it as a filename in a dialog box, and leave it editable for the user to interact,
- Save as: - either in a user-defined folder,
-or on the desk if too complicated.
I put you my piece of code made with the help of different tutorials/codes retrieved right and left
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Dim PartPath As String
Dim Pathsize As Long
Dim PathNoExtension As String
Dim NewFileName As String
Dim Workbooks As Integer
PartPath = Part.GetPathName
Pathsize = Strings.Len(PartPath)
PathNoExtension = Strings.Left(PartPath, Pathsize - 7)
'NewFileName = InputBox("Fill in the new name retrieved in excel", "Save a copy", NewFileName)
'If NewFileName = "" Then
NewFileName = Workbooks("DESIGNTABLE"). WorkSheets("Sheet1"). Cells(1, 9)
'End If
longstatus = Part.SaveAs2(NewFileName & ".sldprt", 0, 1, 0)
'swApp.CloseDoc PartPath 'closes old document
Set Part = swApp.OpenDoc6(NewFileName & ".sldprt", 1, 0, "", longstatus, longwarnings)
End Sub