+ Reply to Thread
Results 1 to 6 of 6

Issue with VBA - Save as macro enabled workbook - address problem.

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    884

    Issue with VBA - Save as macro enabled workbook - address problem.

    Morning happy campers,
    I'm not entirely sure if you can sort this -

    I have the following code that should copy the selected tab, paste into new workbook, save this workbook to the designated location, then close it.
    Sub Macro5()
    '
    ' Macro5 Macro
    '
    
    '
        Sheets("H.K Template").Select
        Sheets("H.K Template").Copy
          newFile = Application.UserName & " - " & Format$(Date, "dd-mmm-yy")
        ChDir _
    "\\emea\uk\MAG_GROUP\division\WHOUSE\LOGISTICS\Supervisor's\Housekeeping\Completed Checks"
        ActiveWorkbook.SaveAs Filename:=newFile
          "\\emea\uk\MAG_GROUP\division\WHOUSE\LOGISTICS\Supervisor's\Housekeeping\Completed Checks"
            FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
        ActiveWindow.Close
    End Sub
    However, the following line is highlighted in red.
          "\\emea\uk\MAG_GROUP\division\WHOUSE\LOGISTICS\Supervisor's\Housekeeping\Completed Checks"
            FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
    Would anyone be able to have a stab at this for me?

    Regards, galvinpaddy

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Issue with VBA - Save as macro enabled workbook - address problem.

    Your code doesn't specify the Drive, maybe this will work

    Sub Macro5()
        Dim NewFile As String
        Const sPath As String = "C:\emea\uk\MAG_GROUP\division\WHOUSE\LOGISTICS\Supervisor's\Housekeeping\Completed Checks"
        
        Sheets("H.K Template").Copy
        NewFile = Application.UserName & " - " & Format$(Date, "dd-mmm-yy")
        ChDir sPath
        ActiveWorkbook.SaveAs Filename:=sPath & NewFile & ".xlsm", _
            FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
        ActiveWorkbook.Close True
    End Sub
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    884

    Re: Issue with VBA - Save as macro enabled workbook - address problem.

    HAHAHAHA, (wait until the IT 'EXPERTS' get back on site)
    you sir are a legend.
    Mate, many many thanks for that, really, REALLY appreciated indeed.

    Kind Regards
    Galvinpaddy
    **Edit***
    Is there anyway i can stop the code from showing the attached message?
    Attached Images Attached Images
    Last edited by galvinpaddy; 07-09-2012 at 01:54 AM.

  4. #4
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    884

    Re: Issue with VBA - Save as macro enabled workbook - address problem.

    Hi Roy,
    Thanks for the, the drive is W:
    My original code contained the address
    W:\LOGISTICS\Supervisor's\Housekeeping\Completed Checks
    and was told it needed to be the way it currently is, but i will give it a shot now and try

    regards

  5. #5
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    884

    Re: Issue with VBA - Save as macro enabled workbook - address problem.

    Hi Roy,
    Sorry, ignore that, moment of monday madness, hadnt copied all of your code. now works lush.

    Cheers again

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Issue with VBA - Save as macro enabled workbook - address problem.

    Glad it helped & thanks for the rep

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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