Forum

Close to open Share...
 
Notifications
Clear all

Close to open SharePoint file but not getting it

5 Posts
3 Users
0 Reactions
200 Views
(@scotty81)
Posts: 46
Trusted Member
Topic starter
 

OK, from Mynda's webinars, I know how to open a file on a local drive using the

Application.GetOpenFileName method. 

And from Google searches, I see how to navigate to a SharePoint folder and select a file via this code.

With Application.FileDialog(msoFileDialogOpen)
.InitialFileName = "https://"Specific SharePoint Path" & ""
.Show
End With

But the part I don't get, and what I'm trying to do is allow a user to open the file they select and then perform manipulations on it e.g. copy cells from that SharePoint file onto my local file where I'm running the macro from.

I was hoping that after executing the above code and selecting a file, that I could invoke the GetOpenFileName method and grab the file.  But when I do just that, I end up selecting my desired Excel file (but then it doesn't do anything further with that file).  Next, Excel executes the GetOpenFileName method but just opens up to a local folder on my hard drive and NOT the SharePoint folder.  Does anyone know how to bring it all together to allow a user to open their file of interest in a SharePoint folder that is pre-specified for them?

Many thanks.

 
Posted : 14/11/2023 1:25 pm
(@keebellah)
Posts: 373
Reputable Member
 

Hi, the only thing I know when adressing SharePoint links is that you may NOT use spaces but have to replace them with %20

 
Posted : 15/11/2023 3:26 am
(@debaser)
Posts: 836
Member Moderator
 

GetOpenFilename doesn't open workbooks. It appears that all you need is to amend the original code to something like this:

With Application.FileDialog(msoFileDialogOpen)
.InitialFileName = "https://"Specific SharePoint Path" & ""
If .Show = -1 then .Execute
End With

 
Posted : 15/11/2023 11:33 am
(@scotty81)
Posts: 46
Trusted Member
Topic starter
 

Hi Velouria,

That worked!  How succinct and functional!  As you can probably tell, I'm a novice Excel VBA programmer.  So, I was (and still) unaware of the nuances of the various Excel objects, their properties, and methods.

Many thanks.

Scotty81

 
Posted : 15/11/2023 1:08 pm
(@debaser)
Posts: 836
Member Moderator
 

Glad we could help. 🙂

 
Posted : 16/11/2023 3:56 am
Share: