Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Rename files and save them as pdf

The main folder, say c:\main contains subfolders c:\main\one, c:\main
\two..., and in each of these subfolders there is one text file named
summary.txt.

The macro needs to:

1. get the summary.txt from each folder
2. rename the file to the name of the subfolder from which it was
opened
3. convert/print renamed file to a pdf file with the same name, e.g
one.pdf, two.pdf...
4. save pdf file to the specified folder, say c:\renamedfiles

Can you please suggest the code?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Rename files and save them as pdf

Try recording a macro of you doing this manually. The recorded code will
give you a great head start.

--

Rod Gill

"Braca" wrote in message
oups.com...
The main folder, say c:\main contains subfolders c:\main\one, c:\main
\two..., and in each of these subfolders there is one text file named
summary.txt.

The macro needs to:

1. get the summary.txt from each folder
2. rename the file to the name of the subfolder from which it was
opened
3. convert/print renamed file to a pdf file with the same name, e.g
one.pdf, two.pdf...
4. save pdf file to the specified folder, say c:\renamedfiles

Can you please suggest the code?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Rename files and save them as pdf

On Feb 10, 10:21 pm, "Rod Gill" <rod AT project-systems DOT co DOT nz
wrote:
Try recording a macro of you doing this manually. The recorded code will
give you a great head start.


Tried it already. Recorded macro will not show me the most important
part - how to extract the name of each subfolder and assign it to the
renamed text file, and how to do all that in a loop until the last
subfolder is reached.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Rename files and save them as pdf

Hi,

Suggest you have a look at the "Dir" function in VBA Help. The example lists
all sub-directories in a given directory.

This gives you the loop you want.

Each time through the loop you get the next directory name in MyName, e.g.
"One".
Place your recorded code where the Debug.Print statement is in the example
and
replace the "one.txt" in your recorded macro with MyName & ".txt"

This should answer your questions so far.


--
Gerd


"Braca" wrote:

On Feb 10, 10:21 pm, "Rod Gill" <rod AT project-systems DOT co DOT nz
wrote:
Try recording a macro of you doing this manually. The recorded code will
give you a great head start.


Tried it already. Recorded macro will not show me the most important
part - how to extract the name of each subfolder and assign it to the
renamed text file, and how to do all that in a loop until the last
subfolder is reached.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Rename files and save them as pdf

You know what you want to do better than I, but renaming a file from .txt to
..pdf doesn't make it a pdf file.

--
Regards,
Tom Ogilvy

"gerdmain" wrote in message
...
Hi,

Suggest you have a look at the "Dir" function in VBA Help. The example
lists
all sub-directories in a given directory.

This gives you the loop you want.

Each time through the loop you get the next directory name in MyName, e.g.
"One".
Place your recorded code where the Debug.Print statement is in the example
and
replace the "one.txt" in your recorded macro with MyName & ".txt"

This should answer your questions so far.


--
Gerd


"Braca" wrote:

On Feb 10, 10:21 pm, "Rod Gill" <rod AT project-systems DOT co DOT nz
wrote:
Try recording a macro of you doing this manually. The recorded code
will
give you a great head start.


Tried it already. Recorded macro will not show me the most important
part - how to extract the name of each subfolder and assign it to the
renamed text file, and how to do all that in a loop until the last
subfolder is reached.






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
Save and rename Steve Excel Discussion (Misc queries) 6 February 27th 09 04:22 PM
How do I rename files that are related. FinnSchH2 Excel Discussion (Misc queries) 2 August 31st 07 02:12 PM
Help to rename files Hilton Excel Worksheet Functions 7 July 7th 07 03:51 AM
Rename Excel Files timwell Excel Programming 2 September 30th 06 12:47 PM
Rename Files Dominique Feteau Excel Programming 1 July 13th 04 11:19 PM


All times are GMT +1. The time now is 10:25 AM.

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"