PC Review


Reply
Thread Tools Rate Thread

Dialog to set path

 
 
Lance Hoffmeyer
Guest
Posts: n/a
 
      9th Jan 2008
Hey all,

I can set a filename with

sFileName = Application.GetOpenFilename

Is there a similar way to set the path as a variable?

Currently I am using a command:

Set oDoc = oAPP.OpenDataDoc("C:\January\File.xls")

with a bunch of editting to File.xls

I would like to change this to

Set oDoc = oAPP.OpenDataDoc(strPATH + "File.xls")

where I have opened some sort of dialog to set the Path for the current month.

Thanks in advance,

Lance
 
Reply With Quote
 
 
 
 
Rick S.
Guest
Posts: n/a
 
      9th Jan 2008
I got this code from this newsgroup, just sharing,

'=======
'Your sub here
sNewItem = InputBox(prompt:="Enter Entire Path for Folder Location!")
On Error Resume Next
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set Folder = oFSO.GetFolder(sNewItem) '"M:\Qadocs\IPI'S\Test Folder"
'do more code here
'======
This snippet from the above code, "M:\Qadocs\IPI'S\Test Folder" is a default
value, change it to whatever you may need.

HTH
--
Regards

VBA.Noob.Confused
XP Pro
Office 2007



"Lance Hoffmeyer" wrote:

> Hey all,
>
> I can set a filename with
>
> sFileName = Application.GetOpenFilename
>
> Is there a similar way to set the path as a variable?
>
> Currently I am using a command:
>
> Set oDoc = oAPP.OpenDataDoc("C:\January\File.xls")
>
> with a bunch of editting to File.xls
>
> I would like to change this to
>
> Set oDoc = oAPP.OpenDataDoc(strPATH + "File.xls")
>
> where I have opened some sort of dialog to set the Path for the current month.
>
> Thanks in advance,
>
> Lance
>

 
Reply With Quote
 
Rick S.
Guest
Posts: n/a
 
      9th Jan 2008
The snippet I quoted is actually "rem" out, so do not use that protion.
--
Regards

VBA.Noob.Confused
XP Pro
Office 2007



"Rick S." wrote:

> I got this code from this newsgroup, just sharing,
>
> '=======
> 'Your sub here
> sNewItem = InputBox(prompt:="Enter Entire Path for Folder Location!")
> On Error Resume Next
> Set oFSO = CreateObject("Scripting.FileSystemObject")
> Set Folder = oFSO.GetFolder(sNewItem) '"M:\Qadocs\IPI'S\Test Folder"
> 'do more code here
> '======
> This snippet from the above code, "M:\Qadocs\IPI'S\Test Folder" is a default
> value, change it to whatever you may need.
>
> HTH
> --
> Regards
>
> VBA.Noob.Confused
> XP Pro
> Office 2007
>
>
>
> "Lance Hoffmeyer" wrote:
>
> > Hey all,
> >
> > I can set a filename with
> >
> > sFileName = Application.GetOpenFilename
> >
> > Is there a similar way to set the path as a variable?
> >
> > Currently I am using a command:
> >
> > Set oDoc = oAPP.OpenDataDoc("C:\January\File.xls")
> >
> > with a bunch of editting to File.xls
> >
> > I would like to change this to
> >
> > Set oDoc = oAPP.OpenDataDoc(strPATH + "File.xls")
> >
> > where I have opened some sort of dialog to set the Path for the current month.
> >
> > Thanks in advance,
> >
> > Lance
> >

 
Reply With Quote
 
Jim Cone
Guest
Posts: n/a
 
      9th Jan 2008

GetOpenFileName returns the path and the file name.
I have never seen your particular Open method used in Excel.
If oApp is an Excel application object then this might be more appropriate...

vFileName = oApp.GetOpenFilename()
If vFileName <> False Then oApp.Workbooks.Open vFileName
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)




"Lance Hoffmeyer"
wrote in message
Hey all,

I can set a filename with

sFileName = Application.GetOpenFilename

Is there a similar way to set the path as a variable?

Currently I am using a command:

Set oDoc = oAPP.OpenDataDoc("C:\January\File.xls")

with a bunch of editting to File.xls

I would like to change this to

Set oDoc = oAPP.OpenDataDoc(strPATH + "File.xls")

where I have opened some sort of dialog to set the Path for the current month.

Thanks in advance,

Lance
 
Reply With Quote
 
Lance Hoffmeyer
Guest
Posts: n/a
 
      9th Jan 2008
The oApp is for SPSS.

Jim Cone wrote:
>
> GetOpenFileName returns the path and the file name.
> I have never seen your particular Open method used in Excel.
> If oApp is an Excel application object then this might be more appropriate...
>
> vFileName = oApp.GetOpenFilename()
> If vFileName <> False Then oApp.Workbooks.Open vFileName

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
File Dialog API - UNC Path =?Utf-8?B?VGFueWE=?= Microsoft Access VBA Modules 4 20th Jul 2007 10:36 PM
specify default path in dialog open box Striker Microsoft Excel Programming 1 12th Aug 2006 02:29 PM
dialog box to pick path & file dlh Microsoft Excel Programming 1 12th Oct 2005 04:36 AM
default path for save as dialog Werner Rohrmoser Windows XP General 2 16th Mar 2005 08:14 AM
server path dialog? rearwindow Microsoft ADO .NET 1 11th Dec 2003 09:32 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:00 AM.