LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default SaveAs

Because you have a common file I would copy the file rather than open the
workbook and perform a SaveAs. The code opens a dialog Box to select the
Templet from the common drive. then creates a local directory GeneratedFiles
if the directory doesn't exist. And finally copies the templet to the
Generated Files directory.


Sub CopyFile()
RootFolder = "C:\"
DestinationFolder = "GeneratedFiles"

Set ScriptObj = CreateObject("Scripting.FileSystemObject")

'Get Templete from Networkfile
filetocopy = Application _
.GetOpenFilename(FileFilter:="Excel Files (*.xls), *.xls", _
Title:="Get Templete")
If filetocopy = False Then
MsgBox ("Cannot Open Templete - Exiting Sub")
Exit Sub
End If

'Check if Folder already exists
Found = False
Set F = ScriptObj.GetFolder(RootFolder)
For Each Folder In F.Subfolders
If Folder.Name = DestinationFolder Then
Found = True
Exit For
End If
Next Folder

'if folder does not exist then create
If Found = False Then
'Generate Folder
ScriptObj.CreateFolder (RootFolder & DestinationFolder)
End If

DestFolder = RootFolder & "GeneratedFiles\"

'get source filename from full path name
Set FileObj = ScriptObj.getfile(filetocopy)
BaseName = FileObj.Name

SourceFile = filetocopy
DestinationFile = DestFolder & BaseName
FileCopy SourceFile, DestinationFile ' Copy source to target.


End Sub


"Arnie" wrote:

Morning all firstly thanks in advance for any answers.

I have a spreadsheet that i want to hold in a shared location when anyone
uses it they copy it to there own PC and place it whereever they want.

I need my Macro to be able to get the filename path so that it can be used
1. to carryout a saveAs and request the new filename
2. to reference the file in other macros
3. to get the file path and create a folder called "GeneratedFiles"

an awfull lot i know but no point in posting lots of questions

Regards Arnie

 
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
SaveAs csv Gert Excel Programming 4 March 21st 07 12:35 PM
More help with SaveAs Glen Mettler[_2_] Excel Programming 2 February 14th 04 02:50 AM
Help with SaveAs Glen Mettler[_2_] Excel Programming 1 February 14th 04 02:48 AM
SaveAs Bill[_19_] Excel Programming 1 January 27th 04 11:11 PM
saveas Nikita Excel Programming 1 September 17th 03 02:39 AM


All times are GMT +1. The time now is 10:41 PM.

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

About Us

"It's about Microsoft Excel"