PDA

View Full Version : date and variable in file SaveAs name



RKFerguson
04-12-2012, 11:27 AM
Hi folks,

I want to save a file from a template and I want the file name to comprise the constant "IRF-" then the date in format ddmmyyyy followed by a variable that gets calculated by VBA code in the macro-enabled template.

I have succeeded in saving the files with the variable as part of the name, but am less than successful adding the date.

Here is what I am trying-

ActiveDocument.SaveAs FileName:="C:\User\xxxxxxx\desktop\IRF-" & Format(Date, "ddmmyyyy") & Format(IRSN, "00#")

Any suggestions? Be kind, I am not a programmer.... ;-)

Thanks,

Fergie

Talis
04-12-2012, 11:50 AM
Dim myDate As String

myDate = Format(Date, "mmddyyyy")
ActiveDocument.SaveAs FileName:="C:\User\xxxxxxx\desktop\IRF-" & myDate & Format(IRSN, "00#")
Put the Dim statement with the other Dims near the beginning of the subroutine that contains the SaveAs statement.

Talis
04-13-2012, 01:41 PM
No response!
Not sure what IRSN is despite Googling for it. Assuming it's a number you would use a similar technique as for date, ie
Dim myIRSN As String
Dim myDate As String
myIRSN = Format(IRSN, "00#")
myDate = Format(Date, "mmddyyyy")
ActiveDocument.SaveAs FileName:="C:\User\xxxxxxx\desktop\IRF-" & myDate & myIRSN

This technique uses Word's ability to switch some types of variable during assignment avoiding the use of functions to do the same thing.

It would be polite of you to respond when someone makes the effort to try and help you.

I see from your previous post:


http://www.vbaexpress.com/forum/showthread.php?t=27207

that you didn't reply then.

fumei
04-13-2012, 02:17 PM
IRSN? I believe it is: "with the variable as part of the name"

A variable.

Should not "that you didn't reply then" be "that you did not reply then...as well"?

<chuckle>

'tis disappointing at times, n'est pas?

</chuckle>

Whoooaa! I just looked at that other post. That was a fairly serious question, and yes, no response. Ummmm. Fergie, there is some reasonable politeness required when posting to forums. Please find out what that is, and use it. Otherwise people will not respond to...you.

Talis
04-13-2012, 10:55 PM
People post things as though their topic is the most urgent and whilst regular posters give up their time to help - the response is often 'zilch'.
Yup, I'm getting disillusioned. Think it's time to head off to my favorite gardening forum, people are polite there. Maybe return here when I've calmed down and feel like wasting more of my time.

fumei
04-14-2012, 11:47 AM
Well that is understandable. And yes gardeners ae generally collectively helpful to each others. Do not stay away too long, you are one of the helpful ones.

Now you know why I often start out by asking what a poster has actually done, before I offer some possible solution. Their response can give a good demonstration of their participation AND their involvement with their own issue. It seems this OP has very little involvement.

brad000123
04-18-2012, 03:15 AM
I just want to save my file in template, that all i want to do . plz any one help me. sorry for my bad English

fumei
04-18-2012, 07:16 PM
And you have been given the answer. What is not working for you?

RKFerguson
10-16-2012, 04:40 PM
To all those kind enogh to reply to my question. I have since resolved the issue. As to not replying... Don't hate, don't castigate. I only just now received notice that anyone had replied to my post....

Fergie:hi: