Eric Penfold
Active Member
- Joined
- Nov 19, 2021
- Messages
- 431
- Office Version
- 365
- Platform
- Windows
- Mobile
When i change the sheet i need to go to a different path. But the Dir does not work??
This line shows ""
This line shows ""
VBA Code:
strFolder = Dir(strPath, vbDirectory)
VBA Code:
Private Sub OpenFolder_Click()
Dim SourcePath As String
Dim SubPath As String
Dim strFolder As String
Dim strPath As String
Dim PDFFName As String
Dim Answer As VbMsgBoxResult
Dim cmbdata
cmbdata = Split(Me.OpenDrawing.Value, "-")
cmbdata(0) = Replace(cmbdata(0), "-", "")
If ActiveSheet.Name = "Frost Drains" Then
SourcePath = "S:\R&D\Drawing Nos\Frost Grates"
GoTo Path
ElseIf ActiveSheet.Name = "DrNo Dic" Then
SourcePath = "S:\R&D\Drawing Nos"
GoTo Path
Path:
If Val(cmbdata(0)) >= 10001 And Val(cmbdata(0)) <= 10050 Then
SubPath = "10001-10050"
ElseIf Val(cmbdata(0)) >= 10051 And Val(cmbdata(0)) <= 10100 Then
SubPath = "10051-10100"
ElseIf Val(cmbdata(0)) >= 10101 And Val(cmbdata(0)) <= 10150 Then
SubPath = "10101-10150"
ElseIf Val(cmbdata(0)) >= 10151 And Val(cmbdata(0)) <= 10200 Then
SubPath = "10151-10200"
End If
strPath = SourcePath & "\" & SubPath & "\" & Int(cmbdata(0))
strFolder = Dir(strPath, vbDirectory)
On Error Resume Next
If strFolder = strFolder Then
ActiveWorkbook.FollowHyperlink Address:=strPath, NewWindow:=True
End If
If strFolder = vbNullString Then
Answer = MsgBox("Folder - Path does not exist. Would you like to create it?", vbYesNo, "Create Folder - Path")
If Answer = vbNo Then
Exit Sub
ElseIf Answer = vbYes Then
VBA.FileSystem.MkDir (strPath)
End If
End If
End If
End Sub