Solved

VBA Excel 2016 - Modify Filedialog using cell reference

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

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

749 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