Pspboy17
Mechanical
- Mar 25, 2024
- 2
Hello everyone,
This is my first thread on here, I'm having some issues with a seemingly simple part of a macro I'm working on.
Just as a bit of background, I'm modifying an existing internal macro that replaces certain segments of our part/product names to reflect a new code for that design. I'm having a problem getting CatVBA to save parts properly when they have a period in the filename. It just saves them as "files" with no extension, going to assume it's getting confused and interpreting the period as the extension.
For instance we might have
12345__0001.0001__Description.catpart
and after I run it through my macro it turns into
54321__0001.0001__Description
With no file extension. I'm not sure how to go about correcting this, and I might just be very confused and going down the wrong road. I found this thread with a macro to know the filetype but I would need some assistance "piping" it into a block of code like below which saves as a particular filetype (not entirely sure where I got this from currently, might have been from this forum). Even then I don't know if it will save correctly.
I've also tried temporarily replacing the period with another character, but I'm confused on how to replace the period back into the filename once it's saved. Any help would be greatly appreciated.
If I'm on the wrong track, is there anyway to get normal save behavior from this command with these part names?
Otherwise I could maybe see "SaveAs partnumber & path & extension" working with the code above, but that seems pretty messy and roundabout.
This is my first thread on here, I'm having some issues with a seemingly simple part of a macro I'm working on.
Just as a bit of background, I'm modifying an existing internal macro that replaces certain segments of our part/product names to reflect a new code for that design. I'm having a problem getting CatVBA to save parts properly when they have a period in the filename. It just saves them as "files" with no extension, going to assume it's getting confused and interpreting the period as the extension.
For instance we might have
12345__0001.0001__Description.catpart
and after I run it through my macro it turns into
54321__0001.0001__Description
With no file extension. I'm not sure how to go about correcting this, and I might just be very confused and going down the wrong road. I found this thread with a macro to know the filetype but I would need some assistance "piping" it into a block of code like below which saves as a particular filetype (not entirely sure where I got this from currently, might have been from this forum). Even then I don't know if it will save correctly.
I've also tried temporarily replacing the period with another character, but I'm confused on how to replace the period back into the filename once it's saved. Any help would be greatly appreciated.
Code:
Select Case "placeholder"
Case "Part"
StoreDoc.Parent.SaveAs newPath, catFileTypeCATPart
Case "Assembly Structure"
StoreDoc.Parent.SaveAs newPath, catFileTypeCATProduct
Case "Drawing"
StoreDoc.Parent.SaveAs newPath, catFileTypeCATDrawing
Case Else
Instance.ReferenceProductParent.SaveAs newPath
End Select
If I'm on the wrong track, is there anyway to get normal save behavior from this command with these part names?
Code:
Instance.ReferenceProduct.Parent.SaveAs
Otherwise I could maybe see "SaveAs partnumber & path & extension" working with the code above, but that seems pretty messy and roundabout.