Solved

VBA Excel 2016 - Modify Filedialog using cell reference

Posted on 2016-07-28
2
59 Views
Last Modified: 2016-07-28
I need to change the filedialog code to reference a cell in my workbook.  I would like to change ChDir = G3, what is the correct syntax.

Public Function Open_FileDialog()
Dim tmpFile

    ChDrive "S:\" 'change the drive also
    ChDir "S:\Corp Accts\Country\Invoices\"

    DoEvents

    tmpFile = Application.GetOpenFilename(FileFilter:="Microsoft Excel Files (.xls),.xls")

    If tmpFile <> False Then
        Workbooks.Open FileName:=tmpFile
    End If
End Function

Open in new window

0
Comment
Question by:Karen Schaefer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 51

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 41733425
Hi,

pls try

Public Function Open_FileDialog()
Dim tmpFile

    ChDrive "S:\" 'change the drive also
    ChDir Range("G3").Value
    DoEvents

    tmpFile = Application.GetOpenFilename(FileFilter:="Microsoft Excel Files (.xls),.xls")

    If tmpFile <> False Then
        Workbooks.Open FileName:=tmpFile
    End If

Open in new window

0
 

Author Closing Comment

by:Karen Schaefer
ID: 41733462
thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question