i want to change the path so it saves to the current file location.

so lets say my current file is 'Z:\cdrfiles\myfile\123'then it should save to the current file open

Dim SaveOptions As StructSaveAsOptions
    Set SaveOptions = CreateStructSaveAsOptions
    With SaveOptions
       .EmbedVBAProject = True
       .Filter = cdrCDR
       .IncludeCMXData = False
        .Range = cdrAllPages
        .EmbedICCProfile = True
        .Version = cdrVersion15
    End With
    ActiveDocument.SaveAs Path, SaveOptions
End Sub
4 Years
Discussion Span
Last Post by AndreRet

More Michael, welkom by Daniweb. Ons reels is dat ek dit in engels hou...

I deliberately used ActiveWorkbook rather than ThisWorkbook - make sure that you understand the difference.

Consider the following (and choose a workbook from a different directory to see the different path names).

Sub Test() 
    Dim filename As Variant 

    MsgBox "ThisWorkbook path is : " & ThisWorkbook.Path 

    filename = Application.GetOpenFilename(Title:="Test") 
    If filename = False Then Exit Sub 

    Workbooks.Open filename:=filename 
    MsgBox "The ActiveWorkbook path is : " & ActiveWorkbook.Path 

End Sub 

An alternative, depending on what you intend doing, would be to assign the newly opened file to a workbook variable so that you could use that, eg wbkName.Path.

You may also be interested in the ExtractPathName function that JW shows HERE. You'll find the file path samples a bit lower down.

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.