Welcome Guest! To access all forums & features, please register an account or sign-in. → Why register?



Save a file by macro


1 reply to this topic - - - - -

#1 Wannes

    iCommand ⌘

  • 9,239 posts
  • Joined: 03-January 04
  • Location: Neowin HQ's Basement
  • OS: Windows 7 | Mac OS X 10.6

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

    Neowinian³

  • 307 posts
  • 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.