Solved

VBA Excel 2016 - Modify Filedialog using cell reference

Posted on 2016-07-28
2
67 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 52

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
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 Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

617 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