I am new to VBA, so apologies for my ignorance. I have a very complicated macro in Excel 2016 that I need to edit. It is related to this previous discussion
I need to change the output save path of a created .pdf. Right now it is using the Excel location as a starting point, (ThisWorkbook.Path) and was saved into that same folder.
But now it needs to save to a different folder which will be on a shared Box drive. The path will change depending on who is accessing the file.
So how should I use Environ$ to indicate that C:\Users\johnsmith\Box\etc. etc. will change and everything after \Box\etc. etc. is constant? It is using values from the Excel spreadsheet to make up the new file name.
Here's the bit I need to edit:
With shDetail
If llRow - 3 < 10 Then
strPDFOutPath = ThisWorkbook.Path & "\2018 Payments\0" & .Cells(llRow, 14).Value & "_" & .Cells(llRow, 3).Value & "_" & "file" & ".pdf"
Else
strPDFOutPath = ThisWorkbook.Path & "\2018 Payments\" & .Cells(llRow, 14).Value & "_" & .Cells(llRow, 3).Value & "_" & "file" & ".pdf"
End If
End With
'Save the form as new PDF file.
objAcroPDDoc.Save 1, strPDFOutPath
So should it be
strPDFOutPath = Environ$(“USERPROFILE”) & Box\Folder1\Folder2\Folder3\0" & .Cells(llRow, 14).Value & "_" & .Cells(llRow, 3).Value & "_" & "file" & ".pdf"
Else
strPDFOutPath = Environ$(“USERPROFILE”) & Box\Folder1\Folder2\Folder3" & .Cells(llRow, 14).Value & "_" & .Cells(llRow, 3).Value & "_" & "file" & ".pdf"
?
This is just an example of what it could look like: