Ajohneus
07-22-2015, 11:29 PM
Hi Sir,
I'm working on something where in the workbook is saved on the deskstop using macro. Saving works just fine. However, when I clicked the cancel button from the input msg I received a runtime error. And when i debug, it points to this path: ThisWorkbook.Saveas (Environ("userprofile") & Application.PathSeparator & "Desktop" & Application.PathSeparator & Filename)
I'm I doing something wrong with the code? Appreciate any help on this.
Thanks,
AJ
Sub Saveas()
'
' Saveas Macro
'
Dim Filenae As Variant
'Dim Filename
Filename = InputBox("ENTER FILE NAME BELOW: (FORMAT: SHOW + MM-DD-YYYY)")
'Macro running but when I click cancel from the input box this error pop up.
'Run-time error '1004':
'The file could not be accessed.
'Make sure the specified folder exists.
'Make sure the folder that contains the file is no read-only
'make sure the file name does not contain any of the following characters: <> ? [] | or *
'make sure the file/path name doesn't contain more than 218
ThisWorkbook.Saveas (Environ("userprofile") & Application.PathSeparator & "Desktop" & Application.PathSeparator & Filename)
I'm working on something where in the workbook is saved on the deskstop using macro. Saving works just fine. However, when I clicked the cancel button from the input msg I received a runtime error. And when i debug, it points to this path: ThisWorkbook.Saveas (Environ("userprofile") & Application.PathSeparator & "Desktop" & Application.PathSeparator & Filename)
I'm I doing something wrong with the code? Appreciate any help on this.
Thanks,
AJ
Sub Saveas()
'
' Saveas Macro
'
Dim Filenae As Variant
'Dim Filename
Filename = InputBox("ENTER FILE NAME BELOW: (FORMAT: SHOW + MM-DD-YYYY)")
'Macro running but when I click cancel from the input box this error pop up.
'Run-time error '1004':
'The file could not be accessed.
'Make sure the specified folder exists.
'Make sure the folder that contains the file is no read-only
'make sure the file name does not contain any of the following characters: <> ? [] | or *
'make sure the file/path name doesn't contain more than 218
ThisWorkbook.Saveas (Environ("userprofile") & Application.PathSeparator & "Desktop" & Application.PathSeparator & Filename)