Solved Open folder form (1 Viewer)

Rob_Jones101

Member
Local time
Today, 17:03
Joined
Aug 8, 2019
Messages
41
Hi

I have a form with a button to open a specific file in a folder. I have recently changed computers and now this wont work. It only works for new folders created and not the ones that were on the old computer.


Private Sub Btnopenfolder_Click()

On Error GoTo Btnopenfolder_Click_Error

Const strParent = "C:\Users\RobertJones\Desktop\Quotes\ "
Dim strQuotenumber As String
Dim Strsite As String
Dim StrprojDesc As String
Dim strFolder As String
Dim Strspace As String

Strspace = Space(1) & "- "

strQuotenumber = Me.QuoteNumber
Strsite = Me.Site
StrprojDesc = Me.Project_Description

strFolder = strParent & strQuotenumber & Strspace & Strsite & Strspace & StrprojDesc
Application.FollowHyperlink "C:\Users\RobertJones\Desktop\Quotes\ " & strFolder

Btnopenfolder_Click_Exit:

Exit Sub

Btnopenfolder_Click_Error:

Select Case Err

Case Else

MsgBox Err & "-" & Error$, vbCritical + vbOKOnly, "Error In btnOpenFolder_Click"
Resume Btnopenfolder_Click_Exit

End Select

End Sub

It keeps saying Error File Not Recognised.

Any help would be appreciated.
 

GaryPanic

Smoke me a Kipper,Skipper
Local time
Today, 10:03
Joined
Nov 8, 2005
Messages
3,296
This is what i use


Private Sub ShowFolder_Click()
Dim stFolder As String

stFolder = "S:\xxxxx\xxxxxxxx\CLIENTS \"
Shell "c:\windows\explorer.exe " & stFolder & Me.QuoteNo, vbNormalFocus




End Sub

not sure if that helps
 

namliam

The Mailman - AWF VIP
Local time
Today, 18:03
Joined
Aug 11, 2003
Messages
11,696
Spaces in filenames.... is it compiling the path properly?

Otherwize try adding "" around the entire path.
 

Rob_Jones101

Member
Local time
Today, 17:03
Joined
Aug 8, 2019
Messages
41
Hi.

Thanks for the help. Been stuck on that all morning and it was just the space after the backslash after quotes that was messing everything up.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:03
Joined
May 7, 2009
Messages
19,169
that is because you are duplicating the "C:\Users\RobertJones\Desktop\Quotes\":


Const strParent = "C:\Users\RobertJones\Desktop\Quotes\ "
...
...
...
strFolder = strParent & strQuotenumber & Strspace & Strsite & Strspace & StrprojDesc
Application.FollowHyperlink "C:\Users\RobertJones\Desktop\Quotes\" & strFolder
 

Users who are viewing this thread

Top Bottom