F
fiona
Hi All,
I have used VBA in Excel several times, so I'm trying to get a handle on it
in Word.
I have a template which I would like to save to a specific location after
people have filled it in. I have (with the help of this group) a macro which
does this, but I'd like to assign a command buton to it.
I have tried to draw in a command button and then copy and paste the macro
to it, but this doesn't seem to work and it also has a habit of making the
template open with the toolbox toolbar in the middle of the page and the
"edit" button pressed. This is very annoying and I can't seem to get rid of
it, even if I unclick the "edit" button and close the toolbox and then save
it again as a .dot template.
This is the macro (if it's important) which doesn't seem to work. It
basically doesn't run if I link it to the command button, but it does if I
keep it as a macro and then use the Macro/Run command.
Private Sub CommandButton1_Click()
'recorded by fiona to try to save this in the correct folder
FilePathName = "S:\Administration\Joanne\Travel\"
strDate = Format(Date, "ddmmyy")
ActiveDocument.SaveAs FileName:=FilePathName & Application.UserName &
strDate, FileFormat:=wdFormatDocument
End Sub
All the lines of working code are one line, this forum seems to have wrapped
it so ignore that. As I said, when it is actually a macro it works, when I
try to use it in a command button it doesn't. I've checked that the command
button's name is correct in the properties box.
Any help would be gratefully received.
Thanks,
Fiona
I have used VBA in Excel several times, so I'm trying to get a handle on it
in Word.
I have a template which I would like to save to a specific location after
people have filled it in. I have (with the help of this group) a macro which
does this, but I'd like to assign a command buton to it.
I have tried to draw in a command button and then copy and paste the macro
to it, but this doesn't seem to work and it also has a habit of making the
template open with the toolbox toolbar in the middle of the page and the
"edit" button pressed. This is very annoying and I can't seem to get rid of
it, even if I unclick the "edit" button and close the toolbox and then save
it again as a .dot template.
This is the macro (if it's important) which doesn't seem to work. It
basically doesn't run if I link it to the command button, but it does if I
keep it as a macro and then use the Macro/Run command.
Private Sub CommandButton1_Click()
'recorded by fiona to try to save this in the correct folder
FilePathName = "S:\Administration\Joanne\Travel\"
strDate = Format(Date, "ddmmyy")
ActiveDocument.SaveAs FileName:=FilePathName & Application.UserName &
strDate, FileFormat:=wdFormatDocument
End Sub
All the lines of working code are one line, this forum seems to have wrapped
it so ignore that. As I said, when it is actually a macro it works, when I
try to use it in a command button it doesn't. I've checked that the command
button's name is correct in the properties box.
Any help would be gratefully received.
Thanks,
Fiona