Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetOpenFilename
Hello,
Within VB6, I have Excel(2000) open and I need to open another workbook using Application.GetOpenFilename(). I am using ChDir and ChDrive before. Eventhough ?App.Path in the immediate windows shows the correct path, when executing the method, another drive and folder is showned in the dialogue box. Is there a way to get it to open where I would like it to open? Your help will be appreciated. Sub prepareTSData() Dim selectedFile As String, saveInThisDir As String Dim theDrive As String, theFolder As String 'display dialog asking user to select a TSData file saveInThisDir = saveInDir(currentFileInfo.fileName) theDrive = Left(fullPath, 1) ChDrive theDrive theFolder = currentFileInfo.fileDir ChDir theFolder selectedFile = Application.GetOpenFilename( _ "Excel Files (*.xls),*.xls", , _ "Select your TSData file", , False) ............ Daniel |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetOpenFilename
ChDrive first then ChDir as per code sample supplied.
Daniel "Orlando Magalhães Filho" a écrit dans le message de ... Hi Daniel, I'm sorry. Are you using ChDir and ChDrive or ChDrive and ChDir? Regards, --- Orlando Magalhães Filho (So that you get best and rapid solution and all may benefit from the discussion, please reply within the newsgroup, not in email)Orlando "Daniel" escreveu na mensagem ... Hello, Within VB6, I have Excel(2000) open and I need to open another workbook using Application.GetOpenFilename(). I am using ChDir and ChDrive before. Eventhough ?App.Path in the immediate windows shows the correct path, when executing the method, another drive and folder is showned in the dialogue box. Is there a way to get it to open where I would like it to open? Your help will be appreciated. Sub prepareTSData() Dim selectedFile As String, saveInThisDir As String Dim theDrive As String, theFolder As String 'display dialog asking user to select a TSData file saveInThisDir = saveInDir(currentFileInfo.fileName) theDrive = Left(fullPath, 1) ChDrive theDrive theFolder = currentFileInfo.fileDir ChDir theFolder selectedFile = Application.GetOpenFilename( _ "Excel Files (*.xls),*.xls", , _ "Select your TSData file", , False) ........... Daniel |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetOpenFilename
Try this: It will open your temp folder for example and set it back to
origenal folder when you are ready Sub test2() Dim SaveDriveDir As String Dim fname As Variant SaveDriveDir = CurDir ChDrive Environ$("temp") ChDir Environ$("temp") Dim wb As Workbook fname = Application.GetOpenFilename(filefilter:="Excel Files (*.xls), *.xls") If fname < False Then Set wb = Workbooks.Open(fname) MsgBox "your code" wb.Close End If ChDrive SaveDriveDir ChDir SaveDriveDir End Sub -- Regards Ron de Bruin (Win XP Pro SP-1 XL2002 SP-2) www.rondebruin.nl "Daniel" wrote in message ... ChDrive first then ChDir as per code sample supplied. Daniel "Orlando Magalhães Filho" a écrit dans le message de ... Hi Daniel, I'm sorry. Are you using ChDir and ChDrive or ChDrive and ChDir? Regards, --- Orlando Magalhães Filho (So that you get best and rapid solution and all may benefit from the discussion, please reply within the newsgroup, not in email)Orlando "Daniel" escreveu na mensagem ... Hello, Within VB6, I have Excel(2000) open and I need to open another workbook using Application.GetOpenFilename(). I am using ChDir and ChDrive before. Eventhough ?App.Path in the immediate windows shows the correct path, when executing the method, another drive and folder is showned in the dialogue box. Is there a way to get it to open where I would like it to open? Your help will be appreciated. Sub prepareTSData() Dim selectedFile As String, saveInThisDir As String Dim theDrive As String, theFolder As String 'display dialog asking user to select a TSData file saveInThisDir = saveInDir(currentFileInfo.fileName) theDrive = Left(fullPath, 1) ChDrive theDrive theFolder = currentFileInfo.fileDir ChDir theFolder selectedFile = Application.GetOpenFilename( _ "Excel Files (*.xls),*.xls", , _ "Select your TSData file", , False) ........... Daniel |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetOpenFilename
Hi all,
The GetOpenFileName processed within Excel will use its own Default of Application, so changing it for a moment will give good results, even its easier to use Comdlg as Component or the API Sub SaveXLSToFolder(Optional strFolder) Dim strXLPath As String Dim myAPP As Excel.Application Dim strXLSFile If IsMissing(strFolder) Then strFolder = App.Path End If 'To have an instance, comment out or set to former Object of Type Excel.Application Set myAPP = New Excel.Application With myAPP strXLPath = .DefaultFilePath .DefaultFilePath = strFolder strXLSFile = .GetOpenFilename(filefilter:="Excel Files (*.xls), *.xls") .DefaultFilePath = strXLPath .Quit End With Set myAPP = Nothing If strXLSFile < False Then MsgBox "The File will be saved as " & strXLSFile End If End Sub Heiko :-) "Orlando Magalhães Filho" wrote: Hi Daniel, I'm sorry. Are you using ChDir and ChDrive or ChDrive and ChDir? Regards, --- Orlando Magalhães Filho (So that you get best and rapid solution and all may benefit from the discussion, please reply within the newsgroup, not in email)Orlando "Daniel" escreveu na mensagem ... Hello, Within VB6, I have Excel(2000) open and I need to open another workbook using Application.GetOpenFilename(). I am using ChDir and ChDrive before. Eventhough ?App.Path in the immediate windows shows the correct path, when executing the method, another drive and folder is showned in the dialogue box. Is there a way to get it to open where I would like it to open? Your help will be appreciated. Sub prepareTSData() Dim selectedFile As String, saveInThisDir As String Dim theDrive As String, theFolder As String 'display dialog asking user to select a TSData file saveInThisDir = saveInDir(currentFileInfo.fileName) theDrive = Left(fullPath, 1) ChDrive theDrive theFolder = currentFileInfo.fileDir ChDir theFolder selectedFile = Application.GetOpenFilename( _ "Excel Files (*.xls),*.xls", , _ "Select your TSData file", , False) ........... Daniel |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Using filename retrieved from GetOpenFilename | Excel Discussion (Misc queries) | |||
GetOpenFilename not returning a usable variable | Excel Discussion (Misc queries) |