Zuccj
06-23-2017, 08:42 AM
In the middle of creating an application, and part of it is that a file will have to be loaded in. The file won't always be the same file, so I just have the folder location open up and let the user select the config file that will be used.
Dim fopen As FileDialog
Set fopen = Application.FileDialog(msoFileDialogOpen)
fopen.Title = "Select Config File"
fopen.InitialFileName = "C:\......"
fopen.Show
Is the current code I have and that works perfectly fine. It opens right up to the correct folder. I've tried a few different ways to get the file to save to a variable, but at the moment haven't had much luck. The file doesn't need to be displayed I just need it saved into a variable so I can manipulate it as needed.
Dim fopen As FileDialog
Dim fcontent As String
Dim textfile As Integer
Set fopen = Application.FileDialog(msoFileDialogOpen)
fopen.Title = "Select Config File"
fopen.InitialFileName = "C:...."
fopen.Show
textfile = FreeFile
Open EvenLogDir & fopen For Input As #textfile
fcontent = Input(LOF(textfile), textfile)
Close #textfile
I'm working with this, and now I'm getting a run-time error 53: File not Found. Not sure how I'm getting that as I'm clicking on the exact file for it to load it, so it should have the exact path.
Dim fopen As FileDialog
Set fopen = Application.FileDialog(msoFileDialogOpen)
fopen.Title = "Select Config File"
fopen.InitialFileName = "C:\......"
fopen.Show
Is the current code I have and that works perfectly fine. It opens right up to the correct folder. I've tried a few different ways to get the file to save to a variable, but at the moment haven't had much luck. The file doesn't need to be displayed I just need it saved into a variable so I can manipulate it as needed.
Dim fopen As FileDialog
Dim fcontent As String
Dim textfile As Integer
Set fopen = Application.FileDialog(msoFileDialogOpen)
fopen.Title = "Select Config File"
fopen.InitialFileName = "C:...."
fopen.Show
textfile = FreeFile
Open EvenLogDir & fopen For Input As #textfile
fcontent = Input(LOF(textfile), textfile)
Close #textfile
I'm working with this, and now I'm getting a run-time error 53: File not Found. Not sure how I'm getting that as I'm clicking on the exact file for it to load it, so it should have the exact path.