SaveAs VBA crashes excel

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:
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
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Post the code that shows how you call the macro.
 
Upvote 0
I have a tried a multitude of ways and nothing seems to work.

Call SaveAs

Application.Run "Filelocation.xlsb!SaveAs"
I have removed my directory tree here but the file is currently saved on my desktop in folder for personal.xlsb which excel opens automatically.
 
Upvote 0
OK, so for the full macro with code embedded not called or run I have ran debug and stepped thru the macro and it works perfectly, however if I just run the macro it crashes excel??
 
Upvote 0
You d
I have a tried a multitude of ways and nothing seems to work.

Call SaveAs

Application.Run "Filelocation.xlsb!SaveAs"
I have removed my directory tree here but the file is currently saved on my desktop in folder for personal.xlsb which excel opens automatically.
'Filelocation' seems like a placeholder, not an actual file name. Didn't you say the macro was in your personal macro workbook? If so, why are you using filelocation.xlsb! instead of personal.xlsb!?
 
Upvote 0
I am not using filelocation.xlsb I typed filelocation as a example which includes personal.xlsb! did you read where I say I removed my directory tree!! :rolleyes:
 
Upvote 0

Forum statistics

Threads
1,215,430
Messages
6,124,851
Members
449,194
Latest member
HellScout

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top