#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Default Dir

Can I declare somewhere in VBA a default directory, such as:

Dim DefaultDir as String
Set DefaultDir = "C:\Documents and Settings\GregR\My Documents\"

and have it apply to all my modules in my personal.xls. TIA

Greg

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Default Dir

You can use a general module and declare the variable:

Option Explicit
Public DefaultDir as String

Then in some other module (workbook_open or auto_open), you can assign the value
to that variable:

Option Explicit
Sub Auto_Open()
defaultdir = "C:\Documents and Settings\GregR\My Documents\"
end sub

You don't need the Set command.

GregR wrote:

Can I declare somewhere in VBA a default directory, such as:

Dim DefaultDir as String
Set DefaultDir = "C:\Documents and Settings\GregR\My Documents\"

and have it apply to all my modules in my personal.xls. TIA

Greg


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Default Dir

Dave, what I am trying to do is assign the variable upon opening my
personal.xls, which has a number of modules, where there is a statement
such as:

SaveAs:"C:\Documents and Settings\GregR\My Documents\" &Folder &
Filename.

When I create, or copy in most cases, a module which has a save
statement, I am constantly repeating my default dir. What I am looking
for, and maybe you have given me the answer all ready, is something
which would look like:

SaveAs: defaultdir & Folder & Filename

Is what you have given me the answer and would I declare and add the
workbook open module to my personal.xls? TIA

Greg

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Default Dir

I'd put this in a General module:

Option Explicit
Public DefaultDir as String
Sub Auto_Open()
defaultdir = "C:\Documents and Settings\GregR\My Documents\"
end sub

That should be enough (unless the variables are cleared for some reason).

GregR wrote:

Dave, what I am trying to do is assign the variable upon opening my
personal.xls, which has a number of modules, where there is a statement
such as:

SaveAs:"C:\Documents and Settings\GregR\My Documents\" &Folder &
Filename.

When I create, or copy in most cases, a module which has a save
statement, I am constantly repeating my default dir. What I am looking
for, and maybe you have given me the answer all ready, is something
which would look like:

SaveAs: defaultdir & Folder & Filename

Is what you have given me the answer and would I declare and add the
workbook open module to my personal.xls? TIA

Greg


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Default Dir

Dave, thanks. I think I got it now

Greg



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Default Dir

Greg

Place this in a module in your Personal.xls outside of any procedures.

Public Const DefaultDir As String = _
"C:\Documents and Settings\GregR\My Documents\"

HTH
Paul

---------------------------------------------------------------------------------------------------------

Can I declare somewhere in VBA a default directory, such as:

Dim DefaultDir as String
Set DefaultDir = "C:\Documents and Settings\GregR\My Documents\"

and have it apply to all my modules in my personal.xls. TIA

Greg


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Default Windows Profile without default Office user info Karen Excel Discussion (Misc queries) 0 November 12th 08 04:53 PM
Default ribbon to open by default when opening xls in browser Hank Excel Discussion (Misc queries) 0 April 10th 08 10:12 PM
0 As Default Value Irfan Excel Worksheet Functions 1 April 1st 08 04:34 PM
Default for Look Up denimead Setting up and Configuration of Excel 0 October 22nd 07 04:17 PM
Default Value? HotRod Excel Programming 2 April 18th 05 01:50 PM


All times are GMT +1. The time now is 10:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"