How do I make a message box to do a save as under a new name?

M

Melody4572

New to this, and so very confused after reading some of the answers on here;
so forgive me in advance.
What I am trying to do is save a word document as a text file but I need to
be able to give the user a pop up message box so that they can save the
informaiton under an ID number to make it easier for our SQL admin to code it
into another program.
This is the code, or rather macro that I am using right now
Sub test()
'
' test Macro
' Macro recorded 6/2/09 Melody
'
ChangeFileOpenDirectory "C:\Documents and Settings\mydesktop\Desktop\"
ActiveDocument.SaveAs FileName:="C:\Documents and
Settings\mydesktop\Desktop\cc testing" & _
Format(Now(), "mm_dd_yyyy hh mm AMPM"), FileFormat:=wdFormatText, _
LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False
Application.Quit
End Sub

It is saving witht he cc test month and date stamp.txt but this does not
help them to enter the information under the correct User ID numbers. Yes,
it is still just being tested so it is really being sent to my desktop. I
will change all that once I get it to where they can work with it. Any help
will be greatly appreciated!
 
G

Gordon Bentley-Mix on news.microsoft.com

Melody,

I'm not quite sure how you want the file name to look so I can't really give
any specific direction; after all, the code you provided is doing exactly
what you told it to do: save the file as a text file with a name that starts
with "cc testing" followed by the date and time. However, apparently this
isn't really what you need, and without an understanding of what you *do*
need... <shrug> A clearer definition of "the correct User ID numbers" would
be helpful.

I will, however, provide some general direction on creating the file name
that might help.

First, I would declare a String variable to use as the file name and set its
value to whatever you want the file name to be - something like:

Dim myFileName as String
myFileName = "C:\Documents and Settings\mydesktop\Desktop\cc testing [the
unique identifier]"
ActiveDocument.SaveAs FileName:=myFileName, FileFormat:=wdFormatText

(Note that you should be able to get away with only specifying the file name
and format arguments for the SaveAs method as these are really the only ones
that matter for your purposes; the rest are just optional, and it looks like
you're using the defaults anyway.)

You could also do something to make "the unique identifier" easier to define
by declaring and setting the value of another String variable like this:

Dim myUniqueIdentifier as String
Dim myFileName as String
myUniqueIdentifier = (whatever you want it to be)
myFileName = "C:\Documents and Settings\mydesktop\Desktop\cc testing " &
myUniqueIdentifier
ActiveDocument.SaveAs FileName:=myFileName, FileFormat:=wdFormatText

This approach allows you to address each part of the process separately -
building the unique identifier, building the file name, saving the document -
which makes modifying the code easier. You might even want to look at using a
function that returns a String value to build the unique identifier, which
would look something like this:

myUniqueIdentifier = fcnBuildUniqueIdentifier

Private Function fcnBuildUniqueIdentifier as String
fcnBuildUniqueIdentifier = (whatever you want it to be, but a function
can come in handy if you're doing something like working with the current
date and time plus something from the document or the environment or some
complex process built from several bits and pieces...)
End Function

If you can tell us what you mean by "the correct User ID numbers" maybe we
can give you better direction, but that's probably the best we can do for now.

BTW, it's probably not such a good idea to use a "live" email address as
your discussion group ID. SPAMMERS regularly grep postings looking for
victims.
--
Cheers!

Gordon Bentley-Mix
Word MVP

Please post all follow-ups to the newsgroup.

Read the original version of this post in the Office Discussion Groups - no
membership required!
 
M

Melody4572

Thank you Gordon for your answer. As for your quesions to me; what I need
for it to do is kind of convoluted, I need the user to be able to save the
file with a push of a button. This part I have as you pointed out.

The way I need to save it instead of by the "cc testing date and time.txt"
is by "account number.txt". The only way this can be done is if they enter
the numbers. I would like them to just press the button have a pop up input
or message box that they can enter this account number in. This is the only
part that I have not automated, and I know it can be done, I guess I just
don't understand how.

Gordon Bentley-Mix on news.microsoft.com said:
Melody,

I'm not quite sure how you want the file name to look so I can't really give
any specific direction; after all, the code you provided is doing exactly
what you told it to do: save the file as a text file with a name that starts
with "cc testing" followed by the date and time. However, apparently this
isn't really what you need, and without an understanding of what you *do*
need... <shrug> A clearer definition of "the correct User ID numbers" would
be helpful.

I will, however, provide some general direction on creating the file name
that might help.

First, I would declare a String variable to use as the file name and set its
value to whatever you want the file name to be - something like:

Dim myFileName as String
myFileName = "C:\Documents and Settings\mydesktop\Desktop\cc testing [the
unique identifier]"
ActiveDocument.SaveAs FileName:=myFileName, FileFormat:=wdFormatText

(Note that you should be able to get away with only specifying the file name
and format arguments for the SaveAs method as these are really the only ones
that matter for your purposes; the rest are just optional, and it looks like
you're using the defaults anyway.)

You could also do something to make "the unique identifier" easier to define
by declaring and setting the value of another String variable like this:

Dim myUniqueIdentifier as String
Dim myFileName as String
myUniqueIdentifier = (whatever you want it to be)
myFileName = "C:\Documents and Settings\mydesktop\Desktop\cc testing " &
myUniqueIdentifier
ActiveDocument.SaveAs FileName:=myFileName, FileFormat:=wdFormatText

This approach allows you to address each part of the process separately -
building the unique identifier, building the file name, saving the document -
which makes modifying the code easier. You might even want to look at using a
function that returns a String value to build the unique identifier, which
would look something like this:

myUniqueIdentifier = fcnBuildUniqueIdentifier

Private Function fcnBuildUniqueIdentifier as String
fcnBuildUniqueIdentifier = (whatever you want it to be, but a function
can come in handy if you're doing something like working with the current
date and time plus something from the document or the environment or some
complex process built from several bits and pieces...)
End Function

If you can tell us what you mean by "the correct User ID numbers" maybe we
can give you better direction, but that's probably the best we can do for now.

BTW, it's probably not such a good idea to use a "live" email address as
your discussion group ID. SPAMMERS regularly grep postings looking for
victims.
--
Cheers!

Gordon Bentley-Mix
Word MVP

Please post all follow-ups to the newsgroup.

Read the original version of this post in the Office Discussion Groups - no
membership required!


New to this, and so very confused after reading some of the answers on here;
so forgive me in advance.
What I am trying to do is save a word document as a text file but I need to
be able to give the user a pop up message box so that they can save the
informaiton under an ID number to make it easier for our SQL admin to code it
into another program.
This is the code, or rather macro that I am using right now
Sub test()
'
' test Macro
' Macro recorded 6/2/09 Melody
'
ChangeFileOpenDirectory "C:\Documents and Settings\mydesktop\Desktop\"
ActiveDocument.SaveAs FileName:="C:\Documents and
Settings\mydesktop\Desktop\cc testing" & _
Format(Now(), "mm_dd_yyyy hh mm AMPM"), FileFormat:=wdFormatText, _
LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False
Application.Quit
End Sub

It is saving witht he cc test month and date stamp.txt but this does not
help them to enter the information under the correct User ID numbers. Yes,
it is still just being tested so it is really being sent to my desktop. I
will change all that once I get it to where they can work with it. Any help
will be greatly appreciated!
 
G

Graham Mayor

Sub MySave()
Dim sFname As String
Start:
sFname = InputBox("Enter account number", "Account Number")
If sFname = "" Then Exit Sub
ActiveDocument.SaveAs FileName:="C:\Documents and
Settings\mydesktop\Desktop\" _
& sFname & ".txt", Fileformat:=wdFormatText
End Sub

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Thank you Gordon for your answer. As for your quesions to me; what I
need for it to do is kind of convoluted, I need the user to be able
to save the file with a push of a button. This part I have as you
pointed out.

The way I need to save it instead of by the "cc testing date and
time.txt" is by "account number.txt". The only way this can be done
is if they enter the numbers. I would like them to just press the
button have a pop up input or message box that they can enter this
account number in. This is the only part that I have not automated,
and I know it can be done, I guess I just don't understand how.

Gordon Bentley-Mix on news.microsoft.com said:
Melody,

I'm not quite sure how you want the file name to look so I can't
really give any specific direction; after all, the code you provided
is doing exactly what you told it to do: save the file as a text
file with a name that starts with "cc testing" followed by the date
and time. However, apparently this isn't really what you need, and
without an understanding of what you *do* need... <shrug> A clearer
definition of "the correct User ID numbers" would be helpful.

I will, however, provide some general direction on creating the file
name that might help.

First, I would declare a String variable to use as the file name and
set its value to whatever you want the file name to be - something
like:

Dim myFileName as String
myFileName = "C:\Documents and Settings\mydesktop\Desktop\cc testing
[the unique identifier]"
ActiveDocument.SaveAs FileName:=myFileName, FileFormat:=wdFormatText

(Note that you should be able to get away with only specifying the
file name and format arguments for the SaveAs method as these are
really the only ones that matter for your purposes; the rest are
just optional, and it looks like you're using the defaults anyway.)

You could also do something to make "the unique identifier" easier
to define by declaring and setting the value of another String
variable like this:

Dim myUniqueIdentifier as String
Dim myFileName as String
myUniqueIdentifier = (whatever you want it to be)
myFileName = "C:\Documents and Settings\mydesktop\Desktop\cc testing
" & myUniqueIdentifier
ActiveDocument.SaveAs FileName:=myFileName, FileFormat:=wdFormatText

This approach allows you to address each part of the process
separately - building the unique identifier, building the file name,
saving the document - which makes modifying the code easier. You
might even want to look at using a function that returns a String
value to build the unique identifier, which would look something
like this:

myUniqueIdentifier = fcnBuildUniqueIdentifier

Private Function fcnBuildUniqueIdentifier as String
fcnBuildUniqueIdentifier = (whatever you want it to be, but a
function can come in handy if you're doing something like working
with the current date and time plus something from the document or
the environment or some complex process built from several bits and
pieces...)
End Function

If you can tell us what you mean by "the correct User ID numbers"
maybe we can give you better direction, but that's probably the best
we can do for now.

BTW, it's probably not such a good idea to use a "live" email
address as
your discussion group ID. SPAMMERS regularly grep postings looking
for victims.
--
Cheers!

Gordon Bentley-Mix
Word MVP

Please post all follow-ups to the newsgroup.

Read the original version of this post in the Office Discussion
Groups - no membership required!


New to this, and so very confused after reading some of the answers
on here; so forgive me in advance.
What I am trying to do is save a word document as a text file but I
need to be able to give the user a pop up message box so that they
can save the informaiton under an ID number to make it easier for
our SQL admin to code it into another program.
This is the code, or rather macro that I am using right now
Sub test()
'
' test Macro
' Macro recorded 6/2/09 Melody
'
ChangeFileOpenDirectory "C:\Documents and
Settings\mydesktop\Desktop\" ActiveDocument.SaveAs
FileName:="C:\Documents and Settings\mydesktop\Desktop\cc testing"
& _ Format(Now(), "mm_dd_yyyy hh mm AMPM"),
FileFormat:=wdFormatText, _ LockComments:=False, Password:="",
AddToRecentFiles:=True, WritePassword _ :="",
ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False,
SaveAsAOCELetter:= _ False
Application.Quit
End Sub

It is saving witht he cc test month and date stamp.txt but this
does not help them to enter the information under the correct User
ID numbers. Yes, it is still just being tested so it is really
being sent to my desktop. I will change all that once I get it to
where they can work with it. Any help will be greatly appreciated!
 
M

Melody4572

Thank you SO very much! I could not for the life of me remember how to save
it this way!

Graham Mayor said:
Sub MySave()
Dim sFname As String
Start:
sFname = InputBox("Enter account number", "Account Number")
If sFname = "" Then Exit Sub
ActiveDocument.SaveAs FileName:="C:\Documents and
Settings\mydesktop\Desktop\" _
& sFname & ".txt", Fileformat:=wdFormatText
End Sub

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Thank you Gordon for your answer. As for your quesions to me; what I
need for it to do is kind of convoluted, I need the user to be able
to save the file with a push of a button. This part I have as you
pointed out.

The way I need to save it instead of by the "cc testing date and
time.txt" is by "account number.txt". The only way this can be done
is if they enter the numbers. I would like them to just press the
button have a pop up input or message box that they can enter this
account number in. This is the only part that I have not automated,
and I know it can be done, I guess I just don't understand how.

Gordon Bentley-Mix on news.microsoft.com said:
Melody,

I'm not quite sure how you want the file name to look so I can't
really give any specific direction; after all, the code you provided
is doing exactly what you told it to do: save the file as a text
file with a name that starts with "cc testing" followed by the date
and time. However, apparently this isn't really what you need, and
without an understanding of what you *do* need... <shrug> A clearer
definition of "the correct User ID numbers" would be helpful.

I will, however, provide some general direction on creating the file
name that might help.

First, I would declare a String variable to use as the file name and
set its value to whatever you want the file name to be - something
like:

Dim myFileName as String
myFileName = "C:\Documents and Settings\mydesktop\Desktop\cc testing
[the unique identifier]"
ActiveDocument.SaveAs FileName:=myFileName, FileFormat:=wdFormatText

(Note that you should be able to get away with only specifying the
file name and format arguments for the SaveAs method as these are
really the only ones that matter for your purposes; the rest are
just optional, and it looks like you're using the defaults anyway.)

You could also do something to make "the unique identifier" easier
to define by declaring and setting the value of another String
variable like this:

Dim myUniqueIdentifier as String
Dim myFileName as String
myUniqueIdentifier = (whatever you want it to be)
myFileName = "C:\Documents and Settings\mydesktop\Desktop\cc testing
" & myUniqueIdentifier
ActiveDocument.SaveAs FileName:=myFileName, FileFormat:=wdFormatText

This approach allows you to address each part of the process
separately - building the unique identifier, building the file name,
saving the document - which makes modifying the code easier. You
might even want to look at using a function that returns a String
value to build the unique identifier, which would look something
like this:

myUniqueIdentifier = fcnBuildUniqueIdentifier

Private Function fcnBuildUniqueIdentifier as String
fcnBuildUniqueIdentifier = (whatever you want it to be, but a
function can come in handy if you're doing something like working
with the current date and time plus something from the document or
the environment or some complex process built from several bits and
pieces...)
End Function

If you can tell us what you mean by "the correct User ID numbers"
maybe we can give you better direction, but that's probably the best
we can do for now.

BTW, it's probably not such a good idea to use a "live" email
address as
your discussion group ID. SPAMMERS regularly grep postings looking
for victims.
--
Cheers!

Gordon Bentley-Mix
Word MVP

Please post all follow-ups to the newsgroup.

Read the original version of this post in the Office Discussion
Groups - no membership required!


:

New to this, and so very confused after reading some of the answers
on here; so forgive me in advance.
What I am trying to do is save a word document as a text file but I
need to be able to give the user a pop up message box so that they
can save the informaiton under an ID number to make it easier for
our SQL admin to code it into another program.
This is the code, or rather macro that I am using right now
Sub test()
'
' test Macro
' Macro recorded 6/2/09 Melody
'
ChangeFileOpenDirectory "C:\Documents and
Settings\mydesktop\Desktop\" ActiveDocument.SaveAs
FileName:="C:\Documents and Settings\mydesktop\Desktop\cc testing"
& _ Format(Now(), "mm_dd_yyyy hh mm AMPM"),
FileFormat:=wdFormatText, _ LockComments:=False, Password:="",
AddToRecentFiles:=True, WritePassword _ :="",
ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False,
SaveAsAOCELetter:= _ False
Application.Quit
End Sub

It is saving witht he cc test month and date stamp.txt but this
does not help them to enter the information under the correct User
ID numbers. Yes, it is still just being tested so it is really
being sent to my desktop. I will change all that once I get it to
where they can work with it. Any help will be greatly appreciated!
 

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