Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub SaveNewVersion_Excel()
- 'PURPOSE: Save file, if already exists add a new version indicator to
- filename
- Dim VersionExt As String
- Dim Saved As Boolean
- Dim x As Long
- Dim path2 As String
- Dim customer As String
- Dim dateVar As String
- Dim partNumber As String
- Dim ws As Worksheet
- Dim wb As Workbook
- 'ws = Workbooks("NDT_Inspection_Form").Worksheets("Sheet1")
- TestStr = ""
- Saved = False
- x = 1
- Workbooks("NDT_Inspection_Form").Activate
- Set ws = Worksheets("Sheet1")
- Sheets("Sheet1").Activate
- customer = Sheet1.Range("B17").Text
- dateVar = Format(Range("N6"), "yymmdd")
- partNumber = Sheet1.Range("B19").Text
- path2 = "S:PublicNDTFPIInspection ReportsArchive" & dateVaryear &
- "" & dateVar & "" & customer & ""
- 'Version Indicator (change to liking)
- VersionExt = "_x"
- 'Need a new version made
- Do While Saved = False
- 'Test to see if file name already exists
- If FileExist(path2 & partNumber & "_x0" & ".pdf") = False Then
- ws.ExportAsFixedFormat Type:=xlTypePDF, Filename:=path2 &
- partNumber & "_x0" & ".pdf", Quality:=xlQualityStandard,
- IncludeDocProperties:=True, IgnorePrintAreas:=False,
- OpenAfterPublish:=False
- Saved = True
- Exit Sub
- ElseIf FileExist(path2 & partNumber & VersionExt & x & ".xlsx") =
- False Then
- ws.ExportAsFixedFormat Type:=xlTypePDF, Filename:=path2 &
- partNumber & VersionExt & x & ".pdf", Quality:=xlQualityStandard,
- IncludeDocProperties:=True, IgnorePrintAreas:=False,
- OpenAfterPublish:=False
- Saved = True
- Else
- x = x + 1
- End If
- Loop
- 'Module 4 - Clears documents of all data for new document submission
- Call ClearAllEntries
- Exit Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement