mdeanh5252
New Member
- Joined
- Sep 5, 2016
- Messages
- 29
Hi,
Been a while since I posted last, but I have ran into a problem adding in a SaveAs routine to an existing macro.
This is what I am trying to add in:
If I save this as its own sub and run it as its own macro after my initial macro runs it will run fine, however when I add it into my existing macro it causes excel to hang then crash not saving the file.
I have tried to call the macro but I get a compile error: Expected variable or procedure, not module or if I use application.run "Filelocation!Macroname" method but I get Run-Time error '1004: Cannot run the macro 'Filelocation!Macroname' The macro may not be availiable in this workbook or all macros may be disabled.
I have the macro saved in my personal.xlsb file so I can call macro to run on any of my template workbook that I open.
So I don't know what I am missing.
Is there another SaveAs routine that someone can share that will do what I'm trying to do?
Thanks
Been a while since I posted last, but I have ran into a problem adding in a SaveAs routine to an existing macro.
This is what I am trying to add in:
VBA Code:
On Error Resume Next
With Application.FileDialog(msoFileDialogSaveAs)
.Title = "Where do you want to save the file?"
.ButtonName = "Save"
.InitialFileName = Application.ActiveWorkbook.Path & Application.PathSeparator & ActiveWorkbook.ActiveSheet.Range("C8").value
If .Show = 0 Then
MsgBox "The file did not save!", vbCritical
Exit Sub
End If
.Execute
End With
If I save this as its own sub and run it as its own macro after my initial macro runs it will run fine, however when I add it into my existing macro it causes excel to hang then crash not saving the file.
I have tried to call the macro but I get a compile error: Expected variable or procedure, not module or if I use application.run "Filelocation!Macroname" method but I get Run-Time error '1004: Cannot run the macro 'Filelocation!Macroname' The macro may not be availiable in this workbook or all macros may be disabled.
I have the macro saved in my personal.xlsb file so I can call macro to run on any of my template workbook that I open.
So I don't know what I am missing.
Is there another SaveAs routine that someone can share that will do what I'm trying to do?
Thanks