Ask Experts Questions for FREE Help !
Ask
    Pajoooo's Avatar
    Pajoooo Posts: 60, Reputation: 1
    Junior Member
     
    #1

    May 20, 2010, 04:09 PM
    Excel VB Script adjust
    I need to save file on c:\abcd\efgh\ijkl folder.

    Part of script that save file on Desktop:

    Dim DTAddress As String
    DTAddress = CreateObject("WScript.Shell").SpecialFolders("Desk top") & Application.PathSeparator & MyDate & "_" & "dan" & "_"
    parm1 = DTAdress & "123456.xls"

    Thanks
    JBeaucaire's Avatar
    JBeaucaire Posts: 5,426, Reputation: 997
    Software Expert
     
    #2

    May 20, 2010, 09:19 PM

    Wouldn't that just be:
    Code:
    Dim DTAddress As String
    
    DTAddress = "C:\abcd\efgh\ijkl\" & MyDate & "_dan_123456.xls"
    ActiveWorkbook.SaveAs DTAddress, xlNormal
    Pajoooo's Avatar
    Pajoooo Posts: 60, Reputation: 1
    Junior Member
     
    #3

    May 22, 2010, 04:21 AM
    That's it!


    Another request
    When I close the file first time, he saved as, for example, 22.05.2010_night_reviewarticle.xls. I need to each following closure of that file one copy kept on the Desktop and the name of the file does not change, regardless of the actual date and time
    Attached Files
  1. File Type: xls Night.xls (46.0 KB, 101 views)
  2. JBeaucaire's Avatar
    JBeaucaire Posts: 5,426, Reputation: 997
    Software Expert
     
    #4

    May 23, 2010, 07:20 AM

    Use this:
    Code:
    Sub If_File_Exists()
    'Jerry Beaucaire   5/23/2010
    'Automatically save two copies of this workbook
    Dim oWSS      As Object
    Dim MyDesktop As String
    Dim MyDate As String
    Dim fPath     As String:    fPath = "C:\ReviewArticle\Archive\Night\"
    Dim fnString  As String:    fnString = "Night_ReviewArticle.xls"
    Application.DisplayAlerts = False
    
        Set oWSS = CreateObject("WScript.Shell")
            With oWSS
                MyDesktop = .SpecialFolders("Desktop") & Application.PathSeparator
            End With
        Set oWSS = Nothing
    
        MyDate = Format(Date, "DD.MM.YYYY_")
        ActiveWorkbook.SaveAs (fPath & MyDate & fnString), xlNormal
        ActiveWorkbook.SaveCopyAs (MyDesktop & fnString)
    
    End Sub
    Pajoooo's Avatar
    Pajoooo Posts: 60, Reputation: 1
    Junior Member
     
    #5

    May 23, 2010, 12:37 PM
    This kept the file in two locations under the names I needed and tis is OK.
    Besides this I need that a saved file with one name forever preserved under this name, regardless of the opening under a different date.
    JBeaucaire's Avatar
    JBeaucaire Posts: 5,426, Reputation: 997
    Software Expert
     
    #6

    May 24, 2010, 02:12 AM

    The macro given should save the file in two places with two different strings:

    C:\ReviewArticle\Archive\Night\DD.MM.YYYY_Night_Re viewArticle.xls


    And then:

    Desktop\Night_ReviewArticle.xls
    Pajoooo's Avatar
    Pajoooo Posts: 60, Reputation: 1
    Junior Member
     
    #7

    May 24, 2010, 03:20 AM
    Yes, it's so.

    I'll try to explain,

    Desktop\Night_ReviewArticle.xls is the working file, and C:\ReviewArticle\Archive\Night\DD.MM.YYYY_Night_Re viewArticle.xls is the archive file.

    Today is 24.05.2010.
    When I close Night.xls file I'll get two files:
    1. Night_ReviewArticle.xls on the Desktop
    2. 24.05.2010_Night_ReviewArticle.xls in C:\ReviewArticle\Archive\Night\

    When I, for example, 31.05.2010. Open this archive file (24.05.2010_Night_ReviewArticle.xls) for inspection and correction, after closing them, in the archives I have a new file 31.05.2010_Night_ReviewArticle.xls, and so the archive becomes unusable.

    I need to just first time archive file be saved as, for example, 24.05.2010_Night_ReviewArticle.xls and that any following closure of that archive file not change its name.
    JBeaucaire's Avatar
    JBeaucaire Posts: 5,426, Reputation: 997
    Software Expert
     
    #8

    May 24, 2010, 09:02 AM

    Well, first thought is that when you open old files, don't allow macros to run on those files for that session. IF you security is set to Medium, it should ask you if it's OK to run macros each time you open a file with macros in them, just say "no" when you're opening an already saved/archived file.

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

IE script error in the script on this page res://ieframe.dll/preview.dlg [ 1 Answers ]

IE script error in the script on this page res://ieframe.dll/preview.dlg

How to adjust carburetor [ 2 Answers ]

I have a **!#$$* Poulan Prolink PPB 250E string trimmer. Just put a new carb on it, thinking that was my problem. It will now at least crank with the choke on and run pretty well, finally winding up to a fairly high rpm. However, no matter how warmed up it gets, when you turn the "choke" from start...

Excel 2007 to have excel 2003 look? [ 6 Answers ]

Hey I have Microsoft Excel 2007, from my course at college I have been given instructions to do a task. However these instructions are for excel 2003. How do I change my excel 07 to look like excel 03 so that it is easier. I know there is a way, help greatly appreicated thanks.

Help mini to adjust [ 1 Answers ]

Mini is a 4yr old chihuahua,I have had here since she was 5 weeks.Mike is 9 weeks and got him 2 days ago.Mini avoids Mike and he just runs to her wanting to play and she wants no part of him.What can I do to help Mini adjust?

Adjust Well Pressure [ 4 Answers ]

I am trying to adjust the pressure on my well. It is at 60 when the water is off and it "starts" when then pressure hits 48, I need to get it down to 40. There are 2 screws I have adjusted both screws, both counter clockwise and clockwise. Neither one seems to lower that pressure. They raise or...


View more questions Search