Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Can VBA Code change itself?

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Can VBA Code change itself?

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Can VBA Code change itself?

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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Can VBA Code change itself?

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 ...
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
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
Change code with code? CLR Excel Programming 2 April 25th 07 07:40 PM
Change code by code. Can you do that? Corey Excel Programming 2 March 1st 07 12:52 AM
Can I use code/macro to change code/macro in an existing file? Scott Bedows Excel Programming 2 February 14th 07 05:50 AM
Code Conflicts With Worksheet Change Code Paige Excel Programming 3 March 3rd 06 04:25 PM
Change to Code Chip Pearson Excel Programming 4 July 28th 03 10:54 PM


All times are GMT +1. The time now is 06:52 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"