VBA to open specific file path using info from userform textbox

S_SSharma1212

New Member
Joined
Apr 22, 2022
Messages
10
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I'm trying to open a specific folder on a network based on the information entered by user. This entered information updates the header info, so cell values won't be accessed. The input corresponds to a number and a name, that would also be part of Folder Name and Workbook Name as well. I've been able to prompt open the save as dialogue box once the user press enters on the form, but the path code I still can't figure out. If someone can help with this please.

Userform.JPG
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Something like
VBA Code:
dim fpath as string
fpath = "C:\data\user\"
/CODE]
then add the strings from the Inputbox
 
Upvote 0
Something like
VBA Code:
dim fpath as string
fpath = "C:\data\user\"
/CODE]
then add the strings from the Inputbox
Thanks, Michael. The issue is that user form input is not exactly the folder name but part of the folder name at a specific address. This is what I'm currently using to open the saveas dialogue box:
VBA Code:
Dim bFileSaveAs As Boolean
    bFileSaveAs = Application.Dialogs(xlDialogSaveAs).Show
 
Upvote 0
Hey Guys, so I am using the following code currently to open up the save as dialogue box. The only issue is it doesn't save in the required file format (i.e. xlsx). I'm calling this sub in my userform okay button code to execute.
All and any help is appreciated.

VBA Code:
Sub filesaveas()

Dim strDefaultPath As String
Dim strDefaultName As String
Dim strDialogBoxName As String
Dim strFilePath As String

strDefaultPath = "X:\Job Folders\"
strDefaultName = "-" & Jobnumber.Value
strDialogBoxName = "Save in the Desired Job Folder"

strFilePath = Application.GetSaveAsFilename(strDefaultPath & _
    strDefaultName)

    If strFilePath = "False" Then
        Exit Sub
    Else
        ActiveWorkbook.SaveAs filename:=strFilePath
    End If

ActiveWorkbook.SaveAs
End Sub
 
Upvote 0
So, using a slightly different approach, I've been able to open the specific location in which I want to save the file. The only issue I'm left with is prefilling the filename and the file type.

This is what I'm currently using to open the saveas dialogue box:
VBA Code:
    ActiveWorkbook.Application.GetSaveAsFilename ManualFolderPath

I've similar process in a word document where the code used to open the saveas dialog is something like this:
VBA Code:
With Dialogs(wdDialogFileSaveAs)
        .Name = ManualFolderPath
        UserSaved = .Show
    End With
I'm trying to figure out the suitable changes to the above word code to be used in the excel sheet.

Thanks for all the help.
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,987
Members
452,373
Latest member
TimReeks

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