![]() |
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 |
How do I set a default path when using Application.GetOpenFilename
Hi
add the following at the beginning ChDir "C:\your_desired_default_location" or ChDir Activeworkbook.path -- Regards Frank Kabel Frankfurt, Germany I am using a macro to help a user put an image into an excel sheet. I would like for the user to be able to click on the button and automatically be browsing the directory that the excel sheet is in, but if not that then I would like to declair a default variable. Currently, when you click button it defaults to "My Documents". The Code Snipit in question is bellow. Any suggestions? Dim filename As String filename = Application.GetOpenFilename("Pictures (*.jpg;*.gif;*.bmp), *.jpgs;*.gif;*.bmp", , "Grab Your Logo", , "False") If filename = "False" Then Application.ScreenUpdating = True Call protect Exit Sub Else Thanks --- Message posted from http://www.ExcelForum.com/ |
How do I set a default path when using Application.GetOpenFilename
I prefer the following as it takes care of different drives and networks
Private Declare Function SetCurrentDirectoryA Lib _ "kernel32" (ByVal lpPathName As String) As Long Sub SetUNCPath(sPath As String) Dim lReturn As Long lReturn = SetCurrentDirectoryA(sPath) If lReturn = 0 Then _ MsgBox "Error setting path." End Sub Bob Flanagan Macro Systems Delaware, U.S. 302-234-9857 http://www.add-ins.com Productivity add-ins and downloadable books on VB macros for Excel "pkohler " wrote in message ... I am using a macro to help a user put an image into an excel sheet. I would like for the user to be able to click on the button and automatically be browsing the directory that the excel sheet is in, but if not that then I would like to declair a default variable. Currently, when you click button it defaults to "My Documents". The Code Snipit in question is bellow. Any suggestions? Dim filename As String filename = Application.GetOpenFilename("Pictures (*.jpg;*.gif;*.bmp), *.jpgs;*.gif;*.bmp", , "Grab Your Logo", , "False") If filename = "False" Then Application.ScreenUpdating = True Call protect Exit Sub Else Thanks --- Message posted from http://www.ExcelForum.com/ |
All times are GMT +1. The time now is 12:31 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com