PC Review


Reply
Thread Tools Rate Thread

Can VBA Code change itself?

 
 
=?Utf-8?B?QmlsbENQQQ==?=
Guest
Posts: n/a
 
      13th Sep 2007
I have a spreadsheet I want to distribute to various people. When it runs,
it pulls data from an outside spreadsheet into itself and processes it. Each
person that I distribute it to will have the data to be pulled in a folder on
their machine. And the spreadsheet I give them will probably be in the same
folder.

Can I set a variable in the code with an initial null value, then put a
textbox on the menu form, have them enter the folder name, then permanently
change the variable value to what they enter, so that the next time they open
the spreadsheet, the folder name they entered last time is already there.

--
Bill @ UAMS
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      13th Sep 2007
I would create a new text file in the users network document and settings
Directory. Give it your own extension and create startup excel information.
When the macro is run have it open the text file and get needed info.

"BillCPA" wrote:

> I have a spreadsheet I want to distribute to various people. When it runs,
> it pulls data from an outside spreadsheet into itself and processes it. Each
> person that I distribute it to will have the data to be pulled in a folder on
> their machine. And the spreadsheet I give them will probably be in the same
> folder.
>
> Can I set a variable in the code with an initial null value, then put a
> textbox on the menu form, have them enter the folder name, then permanently
> change the variable value to what they enter, so that the next time they open
> the spreadsheet, the folder name they entered last time is already there.
>
> --
> Bill @ UAMS

 
Reply With Quote
 
JW
Guest
Posts: n/a
 
      13th Sep 2007
Have a look at GetSetting and SaveSetting in VBA. If you are positive
that the folder containing the files will also be the same folder
where the workbook containing the sode will be stored, you could just
grab the directory of the code workbook and use that.
BillCPA wrote:
> I have a spreadsheet I want to distribute to various people. When it runs,
> it pulls data from an outside spreadsheet into itself and processes it. Each
> person that I distribute it to will have the data to be pulled in a folder on
> their machine. And the spreadsheet I give them will probably be in the same
> folder.
>
> Can I set a variable in the code with an initial null value, then put a
> textbox on the menu form, have them enter the folder name, then permanently
> change the variable value to what they enter, so that the next time they open
> the spreadsheet, the folder name they entered last time is already there.
>
> --
> Bill @ UAMS


 
Reply With Quote
 
Bernie Deitrick
Guest
Posts: n/a
 
      13th Sep 2007
Bill,

In your spreadsheet, use code like this

Dim myPath As String

myPath = ThisWorkbook.Path
ChDir myPath

It will change your default folder for searches, etc. to the folder that the ss file is stored in.

HTH,
Bernie
MS Excel MVP


"BillCPA" <Bill @ UAMS> wrote in message news:159BA241-C6ED-4B1D-97A9-(E-Mail Removed)...
>I have a spreadsheet I want to distribute to various people. When it runs,
> it pulls data from an outside spreadsheet into itself and processes it. Each
> person that I distribute it to will have the data to be pulled in a folder on
> their machine. And the spreadsheet I give them will probably be in the same
> folder.
>
> Can I set a variable in the code with an initial null value, then put a
> textbox on the menu form, have them enter the folder name, then permanently
> change the variable value to what they enter, so that the next time they open
> the spreadsheet, the folder name they entered last time is already there.
>
> --
> Bill @ UAMS



 
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
Run VBA code only worksheet change, but don't trigger worksheet_change event based on what the code does ker_01 Microsoft Excel Programming 6 3rd Oct 2008 09:45 PM
Code to change code in a sheet and workbook module Otto Moehrbach Microsoft Excel Programming 11 11th Nov 2007 07:20 PM
Code Conflicts With Worksheet Change Code =?Utf-8?B?UGFpZ2U=?= Microsoft Excel Programming 3 3rd Mar 2006 04:25 PM
re: How to change grey code to change a DRW results column to a currency value Jim Buyens Microsoft Frontpage 0 25th May 2004 05:24 PM
how do I dynamically change an html meta tag from my code behind code? ntm Microsoft ASP .NET 2 19th Jan 2004 05:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:27 PM.