Jump to content



Photo

Save a file by macro

excel

  • Please log in to reply
1 reply to this topic

#1 Wannes

Wannes

    iCommand ⌘

  • Joined: 03-January 04
  • Location: Belgium
  • OS: Windows 8.1
  • Phone: iPhone 5

Posted 13 December 2012 - 18:49

I would like to save my file by clicking a simple button in an macro-enabled Excel document. The file should be saved as "Date Today" "Value A1". For example: 13-12-2012 LORD HINTON.xlsx

At the moment I thought I had found it but when clicking the button nothing happens. What is wrong with my code? What do I have to change?

Thanks in advance for advising me.

Sub Button133_Click()
	Dim MyDate
	MyDate = Date
	Dim Test1Str As String
	Test1Str = Format(MyDate, "DD-MM-YYYY")
	ThisFile = Range("A1").Value
	Application.DisplayAlerts = False
	Application.Run ("SaveFile")
  
	ActiveWorkbook.SaveCopyAs Filename:="/Gebruikers/Naam/Dropbox/Folder1/Folder2 - Algemeen" & Test1Str & " " & ThisFile & " "
	ActiveWorkbook.Save
	Application.DisplayAlerts = True
End Sub



#2 mastermate

mastermate

    Neowinian

  • Joined: 24-February 04
  • Location: Portland,OR

Posted 13 December 2012 - 20:50

Has the code been assigned to the button you are clicking?
Does the code work without clicking the button?

Just to say, it does work for me, after removing the 'Application.Run("Savefile")' line and changing the destination folder path since these are specific to you.