Add-In procedure not working

Rodster23

New Member
Joined
Sep 17, 2015
Messages
2
Hi,

I have a daily report delivered in CSV format. I do a fair bit of manipulation in a series of macros and then save the file. When I run this on my PC it works fine. When I save the macros to an add-in file format so that others can access them, all of the procedures work except the following save file routine. I am relatively new to macro programming so please forgive any poor style issues. I just don’t understand why this will work on my PC but not as an add-in for others.

Any suggestions?

Cheers,
Rod

====================================
Sub Save_DSS_Daily()
'
' Save the daily report

Dim savefile As String
Dim saveyear As Integer
Dim yearpath As String
Dim i As Integer

On Error GoTo HandleFileError

saveyear = Year(Date)
sheetname = ActiveSheet.Name
yearpath = "Z:\Activity Diagnostic Reports DSS\" & saveyear
filepath = yearpath & "\DSS CSV Files"
savefile = filepath & "\" & sheetname & ".xlsm"

'Futureproofing - if the year changes set up new directory structure

If Dir(yearpath, vbDirectory) = "" Then
MkDir Path:=yearpath
If Dir(filepath, vbDirectory) = "" Then
MkDir Path:=filepath
i = MsgBox(filepath & Chr(13) & Chr(13) & "New directory created for - " & saveyear)
End If
End If

'Save the file

ActiveWorkbook.SaveAs Filename:= _
savefile _
, FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
i = MsgBox(sheetname & ".xlsm" & Chr(13) & Chr(13) & "Saved in:" & Chr(13) & filepath, , "File Saved")

Exit Sub

'If an error, remind the user to save the file

HandleFileError:
i = MsgBox(" Please save as:" & Chr(13) & Chr(13) & sheetname & ".xlsm" & Chr(13) & Chr(13) & " To the directory:" & Chr(13) & Chr(13) & filepath, , "Save file")

End Sub
========================
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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