SOLVED

To prevent file path in Excel VBA

Iron Contributor

Hello Everyone,

 

By using save as dialog box, how to prevent user to change the location path with the help of VBA?

 

My Computer location path is - 

E:\PowerPoint

 

Please help..???

 

Here is a attached file...

3 Replies
best response confirmed by allyreckerman (Microsoft)
Solution

@Excel 

Without VBA:

The general storage location can be set in Excel under File / Options / Save (Excel 2016).

 

With VBA:

Sub Nikolinos_autoSave()
Dim Name
    Name = Application.GetSaveAsFilename("\\MyOwn_nas01\home\Drive\NikolinosPrivatDuc\MUELL\" & Range("B2") & ".xlsm", fileFilter:="Microsoft Excel-Arbeitsmappe (*.xlsm), *.xlsm")
    'In GetSaveFilename you have to enter your file path, be careful with the backschlash where it occurs
    If Name <> False Then
        ActiveWorkbook.SaveAs Name, FileFormat:= _
            xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
    End If
'Range("B2") In this cell you can enter the name of the file
End Sub

 

Finally, your file has also been set up as required :)).

Your file, as understandable, could not be tested for the specified path.

 

I would be happy to know if I could help.

 

Nikolino

I know I don't know anything (Socrates)

 

* Kindly Mark and Vote this reply if it helps please, as it will be beneficial to more Community members reading here.

Thank you so much sir:smiling_face_with_smiling_eyes::smiling_face_with_smiling_eyes:
It helped
1 best response

Accepted Solutions
best response confirmed by allyreckerman (Microsoft)
Solution

@Excel 

Without VBA:

The general storage location can be set in Excel under File / Options / Save (Excel 2016).

 

With VBA:

Sub Nikolinos_autoSave()
Dim Name
    Name = Application.GetSaveAsFilename("\\MyOwn_nas01\home\Drive\NikolinosPrivatDuc\MUELL\" & Range("B2") & ".xlsm", fileFilter:="Microsoft Excel-Arbeitsmappe (*.xlsm), *.xlsm")
    'In GetSaveFilename you have to enter your file path, be careful with the backschlash where it occurs
    If Name <> False Then
        ActiveWorkbook.SaveAs Name, FileFormat:= _
            xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
    End If
'Range("B2") In this cell you can enter the name of the file
End Sub

 

Finally, your file has also been set up as required :)).

Your file, as understandable, could not be tested for the specified path.

 

I would be happy to know if I could help.

 

Nikolino

I know I don't know anything (Socrates)

 

* Kindly Mark and Vote this reply if it helps please, as it will be beneficial to more Community members reading here.

View solution in original post