msoFolderpicker doesn't open any file dialog

mysticmario

Active Member
Joined
Nov 10, 2021
Messages
323
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have this code that should ask for path, but for some reason it does not open any file dialog, what am I missing?
VBA Code:
Sub Publish()
Dim savelociation As String
Dim ChDir As FileDialog

ThisWorkbook.Sheets("OTWARTE PROJEKTY").Activate

Set ChDir = Application.FileDialog(msoFileDialogFilePicker)
 'ChDir ("G:\Mój dysk\ArtProInfo v1.5_Shared")
    With ThisWorkbook.PublishObjects("ArtProInfo v1.5_8106")
        .FileName = ChDir & "\" & "index.html"
        .Publish (False)
        .AutoRepublish = False
    End With
Application.DisplayAlerts = False

ThisWorkbook.Sheets("OTWARTE PROJEKTY").Copy
savelocation = ChDir & "\" & "projekty.csv"
ActiveWorkbook.SaveAs FileName:=savelocation, FileFormat:=xlCSV, CreateBackup:=False
ActiveWorkbook.Close

Application.DisplayAlerts = True
ThisWorkbook.Sheets("OTWARTE PROJEKTY").Activate

End Sub
 
Last edited:

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Try to add "ChDir.Show".
VBA Code:
 Set ChDir = Application.FileDialog(msoFileDialogFilePicker)
 ChDir.Show
 
Upvote 0
Solution
Try to add "ChDir.Show".
VBA Code:
 Set ChDir = Application.FileDialog(msoFileDialogFilePicker)
 ChDir.Show
it did help but i cannot later use this path for
.FileName = ChDir & "\" & "index.html"
 
Upvote 0
it did help but i cannot later use this path for
.FileName = ChDir & "\" & "index.html"

Which is why I sent you a link, there is a little more to it than that.
From Analyst Cave (the link I sent you):

VBA Code:
'Show the dialog. -1 means success!
If fDialog.Show = -1 Then
   Debug.Print fDialog.SelectedItems(1)
End If
 
Upvote 0
it did help but i cannot later use this path for
.FileName = ChDir & "\" & "index.html"
IF what you want is a folder path, not a file(s), you should try this:
VBA Code:
    Set ChDir = Application.FileDialog(msoFileDialogFolderPicker)
    ChDir.Show
    myPath = ChDir.SelectedItems(1)
the "myPath" should what you want.
 
Upvote 0
Which is why I sent you a link, there is a little more to it than that.
From Analyst Cave (the link I sent you):

VBA Code:
'Show the dialog. -1 means success!
If fDialog.Show = -1 Then
   Debug.Print fDialog.SelectedItems(1)
End If
I used your source to fix it, thank you.
 
Upvote 0

Forum statistics

Threads
1,216,733
Messages
6,132,410
Members
449,727
Latest member
Aby2024

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