Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Use String from another module

Hey guys,

I hope you are going to understand what i'm trying to create.

I've got this problem:

I've got several Modules (subs) and Userforms. These Macro's are
opening several files located somewhere. Now the problem is, that these
Macro's will jam when everything is stored in an other location (For
example, an USB Stick, is called driver D: on one PC but it could be F:
on another one).

So i thought, maybe it's handy to create a sub with one single line (a
string perhaps?) that contains the very location of the files. So when
i would change that statement, every macro would be changed. I'll Give
you guys an example.


Like in Module 1, i have Macro1. This Macro opens a workbook :

Workbooks.Open("D:\Excel\Test.xls")

This works when the USB stick is driver D: But when the driver is
called F: it wouldn't work. The result is that i have to go through all
modules and subs, changing the path's. I would like a sub in Module 2,
that only contains the first part of the path. Like this:

Sub Directory()

Driver = "D:\"

End Sub

After that i would like the Sub in Module 1 uses the sub from module 2
like this:

Sub OpenWB()

Workbooks.Open (Cstr(Driver) & "Excel\Test.xls")

End Sub

But i don't have a clue how to realise this, so could anyone help me?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Use String from another module

at the top of one of the general modules in the declarations section above
all procedures/subs/functions.

Public Const Driver as String = "D:\"

--
Regards,
Tom Ogilvy


"Silencer116" wrote:

Hey guys,

I hope you are going to understand what i'm trying to create.

I've got this problem:

I've got several Modules (subs) and Userforms. These Macro's are
opening several files located somewhere. Now the problem is, that these
Macro's will jam when everything is stored in an other location (For
example, an USB Stick, is called driver D: on one PC but it could be F:
on another one).

So i thought, maybe it's handy to create a sub with one single line (a
string perhaps?) that contains the very location of the files. So when
i would change that statement, every macro would be changed. I'll Give
you guys an example.


Like in Module 1, i have Macro1. This Macro opens a workbook :

Workbooks.Open("D:\Excel\Test.xls")

This works when the USB stick is driver D: But when the driver is
called F: it wouldn't work. The result is that i have to go through all
modules and subs, changing the path's. I would like a sub in Module 2,
that only contains the first part of the path. Like this:

Sub Directory()

Driver = "D:\"

End Sub

After that i would like the Sub in Module 1 uses the sub from module 2
like this:

Sub OpenWB()

Workbooks.Open (Cstr(Driver) & "Excel\Test.xls")

End Sub

But i don't have a clue how to realise this, so could anyone help me?


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
code in module A to not execute a Worksheet_SelectionChange sub of another module Jack Sons Excel Discussion (Misc queries) 4 December 11th 05 11:52 PM
Run worksheet module code from workbook module? keithb Excel Programming 1 August 14th 05 04:04 AM
Calls from sheet module to ThisWorkbook module quartz[_2_] Excel Programming 2 June 23rd 05 03:37 PM
Excel VBA to search all macro code in Excel module for specific string criteria Roger1947 Excel Programming 0 May 19th 04 05:51 PM
Variable from a sheet module in a class module in XL XP hglamy[_2_] Excel Programming 2 October 14th 03 05:48 PM


All times are GMT +1. The time now is 05:50 PM.

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

About Us

"It's about Microsoft Excel"