Saves as button

T

Ticotion

Hi

I have a small problem. I have made a button where when the user pess it
saves the current excel shetet in a specific file location. The current code
I use is.

Private Sub CommandButton1_Click()
With ActiveSheet
..Parent.SaveAs Filename:="N:\3 PTA & Vedligehold\6 Dokumentation\4 Plast\1
Sprøjtestøbemaskiner\190112\" & "Checkliste Sprøjtestøbemaskine" & " " &
..Range("C2").Value & ".xls", _
FileFormat:=xlWorkbookNormal
End With
' End Sub

As the directory folder changes according to a specific cell value I want to
automate this. In the example above the directory path is N:\3 PTA &
Vedligehold\6 Dokumentation\4 Plast\1 Sprøjtestøbemaskiner\190112\

190112 should change according to a specific celle value. How do I co this?
I've been trying something like this

..Parent.SaveAs Filename:="N:\3 PTA & Vedligehold\6 Dokumentation\4 Plast\1
Sprøjtestøbemaskiner\" & .Range("C2").Value & "\" & "Checkliste
Sprøjtestøbemaskine" & ".xls", _

Can you help?

Ticotion
 
B

Bob Phillips

Private Sub CommandButton1_Click()
Const FILE_ROOT As String = _
"N:\3 PTA & Vedligehold\6 Dokumentation\4 Plast\" & _
"1 Sprøjtestøbemaskiner\<dir>\Checkliste Sprøjtestøbemaskine"
With ActiveSheet
.Parent.SaveAs _
Filename:=Replace(FILE_ROOT, "<dir>", .Range("C2").Value) &
".xls", _
FileFormat:=xlWorkbookNormal
End With

End Sub
 
T

Ticotion

That works. Thank you for your quick reply


Bob Phillips said:
Private Sub CommandButton1_Click()
Const FILE_ROOT As String = _
"N:\3 PTA & Vedligehold\6 Dokumentation\4 Plast\" & _
"1 Sprøjtestøbemaskiner\<dir>\Checkliste Sprøjtestøbemaskine"
With ActiveSheet
.Parent.SaveAs _
Filename:=Replace(FILE_ROOT, "<dir>", .Range("C2").Value) &
".xls", _
FileFormat:=xlWorkbookNormal
End With

End Sub


--
__________________________________
HTH

Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top