Macro opening folder but not going any further

ghrek

Active Member
Joined
Jul 29, 2005
Messages
426
Hi

I have the following macro that opens a folder but when I go to click on one of the files within it once opened it dont do nothing and I need it to open next file I selected.

Any ideas?


Sub OPENWAFOLDER()
'
' OPENWAFOLDER Macro
'
ChDrive "T:"
ChDir "T:\Passenger Accounts\WA"
Application.GetOpenFilename
End Sub
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
GetOpenFileName returns a STRING if file is selected
- as the name suggests it gets the name of the file to open (including the full path)

read this
https://docs.microsoft.com/en-us/office/vba/api/excel.application.getopenfilename

This helps clarify above and shows you how to structure your code so that it does not fail if something is not selected

Code:
Sub OpenAWorkbook()
    Dim fileToOpen As Variant

[COLOR=#006400]'get the full path of the file[/COLOR]
    fileToOpen = Application.GetOpenFilename
    
    
    If fileToOpen <> False Then
        MsgBox fileToOpen
        Workbooks.Open (fileToOpen)
    Else
        MsgBox "Nothing selected"
    End If
End Sub
 
Last edited:
Upvote 0
Thanks for that.

When im saving it as a read/write on my PC it fine but when someone else open the sheet where the macro buttons are on another PC as read only when they click on macro button it not working?

They opened it after I had saved the document. Any ideas?
 
Upvote 0
Scenario
You are saving as read\write
User is opening as Read Only
User clicks on button
Button does not work

1 Please post button VBA
2 Does button respond ? - test by inserting a message box as the first line of button code
3 Does button work normally if user opens as read\write ?

thanks
 
Upvote 0

Forum statistics

Threads
1,215,430
Messages
6,124,846
Members
449,194
Latest member
HellScout

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top