Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VBA Excel 2016 - Modify Filedialog using cell reference

Posted on 2016-07-28
2
Medium Priority
?
71 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 2000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
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.

722 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