+ Reply to Thread
Results 1 to 2 of 2

Macro to Save File in Two Places (HD & Server) Then Print It

  1. #1
    Registered User
    Join Date
    08-29-2014
    Location
    Albion, NY
    MS-Off Ver
    2010
    Posts
    1

    Macro to Save File in Two Places (HD & Server) Then Print It

    I am running Excel 2010. I have written a macro to save the excel file as a file name which is unique on every save by users. Cell B5 is the current date (28-Aug-14), cell R5 is the machine name and cell D5 is a person's name. Cells R5 and D5 pick from a list from data validation. Using a one press command button, I would like the file to save to two different places (hard drive and server) and then print the worksheet on the default printer. I wrote the following macro for the command button:

    Private Sub CommandButton1_Click()
    Dim Path As String
    Dim FileName1 As String
    Dim FileName2 As String
    Dim FileName3 As String
    Path = "C:\CG-1 Log Sheets\2014\"
    FileName1 = Range("B5")
    FileName2 = Range("R5")
    FileName3 = Range("D5")
    ThisWorkbook.SaveAs Filename:=Path & FileName1 & "." & FileName2 & "." & FileName3 & ".xlsm", FileFormat:=xlNormal
    Path = "V:\h09sv-alb1\albion\CG-1\CG-1 Log Sheets\2014\"
    ThisWorkbook.SaveAs Filename:=Path & FileName1 & "." & FileName2 & "." & FileName3 & ".xlsm", FileFormat:=xlNormal
    End Sub

    Sub Print_Active_Worksheet()
    Application.Dialogs(xlDialogPrint).Show
    End Sub

    That gives me the following reply:

    Run-time error '1004'

    And it highlights in yellow the following line in the macro:

    ThisWorkbook.SaveAs Filename:=Path & FileName1 & "." & FileName2 & "." & FileName3 & ".xlsm", FileFormat:=xlNormal

    It is the first of two lines that are the same in the macro.

    I would appreciate if anybody had any suggestions. Thank you for your help. I appreciate it.


    Gabe

  2. #2
    Registered User
    Join Date
    03-13-2010
    Location
    Mumbai, India
    MS-Off Ver
    2007 & 2013
    Posts
    28

    Re: Macro to Save File in Two Places (HD & Server) Then Print It

    Hi,

    I coopied your code & tried in my PC. You mentioned 1st command of two similar ones. It works perfectly ok in my PC.

    Regards,
    xlman

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copy Save File As then Print macro
    By larzep in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-24-2011, 10:35 PM
  2. Save in PDF on remote server and print it in PDF
    By robert_mim in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-11-2009, 04:04 PM
  3. Unable to save CSV file without decimal places
    By gregp85 in forum Excel General
    Replies: 1
    Last Post: 07-04-2008, 05:10 AM
  4. Cannot Save to file server.
    By ektrules in forum Excel General
    Replies: 1
    Last Post: 09-13-2007, 04:30 PM
  5. [SOLVED] save XL file to server via FTP upload
    By windsurferLA in forum Excel General
    Replies: 0
    Last Post: 12-02-2005, 03:45 AM

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