I would like to transfer a template document to a folder that I am creating with VBA.
I have been working on the FileCopy method but realised I cannot move a document I am using. Is there a method I can use to get around this?
I would like to transfer a template document to a folder that I am creating with VBA.
I have been working on the FileCopy method but realised I cannot move a document I am using. Is there a method I can use to get around this?
An easy approach is two steps:
FileCopy PathAndFileInfo, PathAndCopyInfo
Kill PathAndFileInfo
Or use the Move method of the FileSystemObject approach to file management:
http://msdn.microsoft.com/en-us/libr...ffice.15).aspx
Bernie Deitrick
Excel MVP 2000-2010
Cheers Bernie but I'm not trying to move the document. I am opening a user based document and someone uses it to set up a new user. When they do a new file path is created and a copy of the template document (held elsewhere) is copied into the new filepath with certain info added to the new copy.
When you say fileinfo and copyinfo what d you mean, and is that the exact syntax?
Why not just do SaveCopyAs?
Entia non sunt multiplicanda sine necessitate
Sorry, I misunderstood. I would just use:
Thisworkbook.SaveAs "path and name", 52
Like
ThisWorkbook.SaveAs "M:\My Documents\New Folder\NewBookName.xlsm", 52 ' 52 = Macro Enabled workbook
to the new file path - the workbook is saved in the new folder, and the template is no longer the activeworkbook. If you want the template to remain the activeworkbook, the use
Thisworkbook.SaveCopyAs "M:\My Documents\New Folder\NewBookName.xlsm" 'Extension must match file type
Bernie,
Folder 1 = Template doc I am attempting to copy into Folder 3 (which is the new folder I have created).
Folder 2 = Version of the Folder 1 document that is being used
Sorry people, I still don't have a working solution to this issue?
I've tried something along these lines but it doesn't seem to be working
This is the value of GPath's cell BA4![]()
Please Login or Register to view this content.
![]()
Please Login or Register to view this content.
Last edited by Sc0tt1e; 10-03-2014 at 09:13 AM.
Why does this,
preclude the use of SaveCopyAs?Originally Posted by scottie
If posting code please use code tags, see here.
OK, now I've posted the code I can see how much of a mess this is. I will work on code and if I still have no luck will start afresh.
If however someone can work out what I'm trying to do and suggest a solution that would be greatly appreciated.
Where do you want to copy the workbook to?
Is it the same path as the workbook, wbs, being opened?
![]()
Please Login or Register to view this content.
[/QUOTE]Is it the same path as the workbook, wbs, being opened?[/QUOTE]
The location the document to save to is as above, the location will not be the same as the location the workbook was opened from though.
Template is saved atdocument is called "Tyrant.xlsm"![]()
Please Login or Register to view this content.
Every time a new member of staff is added to the HR database a new filepath is set up for them and a copy of the template document is added to this folder.
Multiple people can set up new users so the starting location of the document will differ depending on who is setting up new people. Also I had a problem trying to determine who was using each version so I have added some code to insert some initials into A1 of Sheet 1 and some changes here and there depending on job role, of the template being copied across so a copy of the version being used is no good due to the changes hence it has to be from the Template location.![]()
Please Login or Register to view this content.
Last edited by Sc0tt1e; 10-03-2014 at 09:12 AM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks