ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I set a default path when using Application.GetOpenFilename (https://www.excelbanter.com/excel-programming/303978-how-do-i-set-default-path-when-using-application-getopenfilename.html)

pkohler[_8_]

How do I set a default path when using Application.GetOpenFilename
 
I am using a macro to help a user put an image into an excel sheet.
would like for the user to be able to click on the button an
automatically be browsing the directory that the excel sheet is in, bu
if not that then I would like to declair a default variable.
Currently, when you click button it defaults to "My Documents". Th
Code Snipit in question is bellow. Any suggestions?

Dim filename As String

filename = Application.GetOpenFilename("Picture
(*.jpg;*.gif;*.bmp), *.jpgs;*.gif;*.bmp", , "Grab Your Logo",
"False")

If filename = "False" Then
Application.ScreenUpdating = True
Call protect
Exit Sub
Else


Thank

--
Message posted from http://www.ExcelForum.com


pkohler[_9_]

How do I set a default path when using Application.GetOpenFilename
 
One Clarifying point.

The path that I want to open is a network path.

I.E. \\ShareName\Folder\et

--
Message posted from http://www.ExcelForum.com


Rob Bovey

How do I set a default path when using Application.GetOpenFilename
 
You can use the SetCurrentDirectoryAPI to set the current directory to
a UNC path. Here's a quick procedure that will do this:

Private Declare Function GetCurrentDirectoryA Lib "kernel32" _
(ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long

Public Sub SetUNCPath(ByVal szPathToSet As String)
SetCurrentDirectoryA szPathToSet
End Sub

Despite the name, it works on regular drive\path strings as well.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"pkohler " wrote in message
...
One Clarifying point.

The path that I want to open is a network path.

I.E. \\ShareName\Folder\etc


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 02:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com