Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default File referencing in macro

Hi,

I'm still very new to this, so please bear with me:

I am developing a series of macros that create a user-defined workbook from
a standard template, and I would like to know how to refer to a workbook in a
macro when it has been saved under a name and file path specified by the user.

The final action of the macros in the template is to save the workbook under
the name sepcified by the user in cell "B3" of the 'setup sheet'. If the
user does not specify a file path (in "B6"), the workbook default-saves to
the C:\Temp folder. This obviously means that the workbook could have any
filepath and any name. (The template will (hopefully) be issued to various
dislocated cost centres for their use).

When I try to run a macro in the new workbook, the macros still refer to the
standard template and therefore do not run.

The macro (DATA_EXTRACT, that I cannot run) in the new workbook extracts
data from an external data file and pastes it into the workbook, where it is
then used to update various other sheets of the workbook.

This is what I currently have:

Sub SAVE_SHEETS

If Sheets("SETUP SHEET").Range("B6") = "" Then
ActiveWorkbook.SaveAs FileName:="C:\TEMP\" & Sheets("SETUP SHEET").Range
("B3") & " MASTER SHEETS.xls", FileFormat _:=xlNormal

Else

ActiveWorkbook.SaveAs FileName:=Sheets("SETUP SHEET").Range("B6") &
Sheets("SETUP SHEET").Range("B3") & " MASTER SHEETS.xls", FileFormat
_:=xlNormal,

End If

End Sub

Sub DATA_EXTRACT

Application.ScreenUpdating = False
Workbooks.Open FileName:="C:\ Temp \ DATA_FILE.xls"
Range("C2:D6000 , H2:H6000").Copy
Windows(**FILE NAME??**).Activate
Sheets("DATA_SHEET").Select
ActiveSheet.Paste
Windows("DATA_FILE").Activate
ActiveWindow.Close

'etc etc...


I hope this makes sense and someone understands what I'm trying to do.
(Maybe there's a way to create macros that aren't specific to a named
workbook???)
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
Referencing closed file TheErick Excel Worksheet Functions 6 January 22nd 09 12:32 AM
Referencing another file/workbook [email protected] Excel Worksheet Functions 4 October 6th 08 01:17 AM
referencing a file name and sheet name Arain Excel Discussion (Misc queries) 7 August 26th 06 02:04 AM
Referencing a 2nd file [email protected] Excel Discussion (Misc queries) 1 May 28th 06 07:24 AM
Referencing a closed file briancrosier Excel Worksheet Functions 2 December 14th 04 04:11 PM


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