Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Creating a folder using macro...


I have a macro that brings up an Input Box which takes a filename
(fnames$) and saves an excel sheet as that filename, I need this to
create a folder first then save itself in the folder. The folder name
would be the same as strProjectNumber...

bk.SaveAs FileName:="C:\LOA\" & strProjectNumber & "\" & fnames$

OK, well obviously the above doesn't work but I am trying to get it to
save as

C:\LOA\ = Then a new folder based on the strProjectName = Then the
filename fnames$ (previously entered from an Input Box (No help needed
with this))

Anyone help?


--
ChrisMattock
------------------------------------------------------------------------
ChrisMattock's Profile: http://www.excelforum.com/member.php...o&userid=33912
View this thread: http://www.excelforum.com/showthread...hreadid=545527

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Creating a folder using macro...


Use

mkdir "C:\LOA\" & strProjectNumber

before you save the file.

Co

--
colofnatur
-----------------------------------------------------------------------
colofnature's Profile: http://www.excelforum.com/member.php...fo&userid=3435
View this thread: http://www.excelforum.com/showthread.php?threadid=54552

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Creating a folder using macro...


Thanks! But if the directory I am trying to make already exists will
that be a problem? Also how would I then enter the save command to
reflect the directory based on strProjectNumber.


--
ChrisMattock
------------------------------------------------------------------------
ChrisMattock's Profile: http://www.excelforum.com/member.php...o&userid=33912
View this thread: http://www.excelforum.com/showthread...hreadid=545527

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Creating a folder using macro...

Hi Chris,

on error resume next
mkdir "C:\LOA\" & strProjectNumber 'if already exists you will get
error
err = 0 'you don't check for this error (either the folder was created
or already exists. Third possibility is write protected disk - not
worth to check, because also saving will fail)
bk.SaveAs FileName:="C:\LOA\" & strProjectNumber & "\" & fnames$
if err<0 then
msgbox "Error while saving"
else
msgbox "Saved"
end if
on error goto 0

Regards,
Ivan

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
Macro creating folder and files automatically, without permission. pokdbz Excel Discussion (Misc queries) 1 November 8th 07 04:24 PM
Creating a new folder cereldine[_33_] Excel Programming 2 May 12th 06 11:48 AM
Creating Folder Folder in My Documents VBA - HELP Ali[_4_] Excel Programming 3 July 25th 05 02:17 PM
Macro for creating folder RG[_2_] Excel Programming 1 December 29th 03 06:53 PM
creating folder Lawson Excel Programming 1 December 3rd 03 01:16 AM


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