+ Reply to Thread
Results 1 to 12 of 12

Macros for saving word file in current folder

  1. #1
    Registered User
    Join Date
    10-27-2010
    Location
    Hyderabad
    MS-Off Ver
    Excel 2007
    Posts
    9

    Unhappy Macros for saving word file in current folder

    I HAVE FOLDER NAMED "TODAY". IN THAT I HAVE AN EXCEL FILE WHICH CONTAINS MACROS FOR CREATING PIVOT TABLE AND COPYING IT IN WORD FILE BY OPENING WORD APPLICATION. I WANT TO SAVE THIS WORD FILE AFTER COPYING IN THE CURRENT FOLDER.

    FURTHER, WHENEVER THIS EXCEL FILE IS COPIED IN ANY OTHER FOLDER OR ANY OTHER COMPUTER THE MACROS SHOULD SAVE THE CREATED WORD FILE IN THAT FOLDER.

    THE FOLLOWING MACROS WRITTEN IN EXCEL FOR SAVING NEWLY CREATED EXCEL FILE IN THE CURRENT FOLDER WORKS.
    Please Login or Register  to view this content.

    LIKEWISE THE FOLLOWING MACROS WRITTEN IN WORD FILE FOR SAVING NEWLY CREATED WORD FILE WORKS.
    Please Login or Register  to view this content.

    BUT THE MACROS CREATED IN EXCEL FOR CREATING WORD FILE AND SAVING THE WORD FILE DOES NOT WORK AND IT SAVES THE WORD FILE IN "MYDOCUMENTS".

    WILL ANYBODY GIVE SOLUTION? THANKS
    Last edited by Leith Ross; 10-29-2010 at 01:44 AM.

  2. #2
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161

    Re: Macros for saving word file in current folder

    Just add this at the top!
    Please Login or Register  to view this content.
    Not all forums are the same - seek and you shall find

  3. #3
    Registered User
    Join Date
    10-27-2010
    Location
    Hyderabad
    MS-Off Ver
    Excel 2007
    Posts
    9

    Macros for saving word file in current folder

    I HAVE THE FOLLOWING MACRO CODE IN EXCEL FILE. TO SAVE THE WORD FILE IN THE FOLDER CONTAINING EXCEL FILE IN WHICH THE MACRO IS WRITTEN WHAT PATH (CODE) I HAVE TO WRITE AND BETWEEN WHICH LINE I HAVE TO WRITE - SO THAT WHENEVER THE EXCEL FILE IS COPIED IN ANY OTHER FOLDER OR COMPUTER THE WORD FILE CREATED WITH MACRO OF EXCEL FILE CAN BE SAVED IN THE SAME FOLDER IN WHICH THE EXCEL FILE IS RESIDENT.
    Please Login or Register  to view this content.
    Last edited by Leith Ross; 10-29-2010 at 01:42 AM.

  4. #4
    Registered User
    Join Date
    10-27-2010
    Location
    Hyderabad
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Macros for saving word file in current folder

    With reference to my above query can any body give solution. Thanks

  5. #5
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161

    Re: Macros for saving word file in current folder

    The suggestion i gave DOES save the document in the correct path!

  6. #6
    Registered User
    Join Date
    10-27-2010
    Location
    Hyderabad
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Macros for saving word file in current folder

    Thanks for the code provided by Simon Lloyd.
    However, it does not work in the following case where the macros is written in excel file. It adds word file and pastes the selected matter in the word file. I want to save the word file thus created in the same folder where the excel file is there. i give below the code and shall be glad if a solution is given as to what code is to be written and where in the following code-

    Please Login or Register  to view this content.

  7. #7
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161

    Re: Macros for saving word file in current folder

    Quote Originally Posted by Simon Lloyd View Post
    Just add this at the top!
    Please Login or Register  to view this content.
    In that case change ActiveDocument for ActiveWorkbook

  8. #8
    Registered User
    Join Date
    10-27-2010
    Location
    Hyderabad
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Macros for saving word file in current folder

    I tried to add both the path viz. "ChDir ActiveDocument.Path" and "ChDir ActiveWorkbook.Path" then also it is not working. What other code I have to write in the above macros code and where I have to write that code. Can you give solution? Thanks.

  9. #9
    Registered User
    Join Date
    10-27-2010
    Location
    Hyderabad
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Macros for saving word file in current folder

    Quote Originally Posted by baluiyer View Post
    I tried to add both the path viz. "ChDir ActiveDocument.Path" and "ChDir ActiveWorkbook.Path" then also it is not working. What other code I have to write in the above macros code and where I have to write that code. Can you give solution? Thanks.

  10. #10
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161

    Re: Macros for saving word file in current folder

    Supply your code as it is now with my suggestion in place.

  11. #11
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Macros for saving word file in current folder

    In VBA there's no use for chdrive or chdir.

    Please Login or Register  to view this content.
    This file "E:\OF\example.doc" will be saved as "E:\OF\new name.doc"

    If the file has to be saved in the same folder as your excelfile:

    Please Login or Register  to view this content.
    Instead of your code I'd rather use:

    Please Login or Register  to view this content.
    It does the same (even more) than:

    Please Login or Register  to view this content.
    Last edited by snb; 11-25-2010 at 04:43 PM.



  12. #12
    Registered User
    Join Date
    10-27-2010
    Location
    Hyderabad
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Macros for saving word file in current folder

    Thank you very much. I substituted my code with your code. It works. Thanks a lot.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1