Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dave, thanks. I think I got it now
Greg |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Default Windows Profile without default Office user info | Excel Discussion (Misc queries) | |||
Default ribbon to open by default when opening xls in browser | Excel Discussion (Misc queries) | |||
0 As Default Value | Excel Worksheet Functions | |||
Default for Look Up | Setting up and Configuration of Excel | |||
Default Value? | Excel Programming |