AllExperts > VB Script 
Search      
VB Script
Volunteer
Answers to thousands of questions
 Home · More VB Script Questions · Answer Library  · Encyclopedia ·
More VB Script Answers
Question Library

Ask a question about VB Script
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Miguel Zapico
Expertise
I can answer question about how to use scripts to consolidate data, connect different systems and automate tasks. I have no experience on using VBScript on web programming.

Experience
I have been using VBScript and Windows Scripting Host as my swiss tool for the last 6 years.

Organizations
New York PC users group (NYPC)
Independant Computer Consultants Association (ICCA)

Education/Credentials
Microsoft MCSE in Windows NT

 
   

You are here:  Experts > Computing/Technology > Basic > VB Script > Using Save As with VBA and Input Boxes

VB Script - Using Save As with VBA and Input Boxes


Expert: Miguel Zapico - 8/9/2006

Question
I need to know how to use input boxes to generate a file name that VB can then use to save the file as, so far I have:
Sub Test()

Dim Employeename As String
Dim Reportdate As Variant

Employeename = InputBox("Enter name")
Reportdate = InputBox("Enter date inthe following format 01.01.1900")
   
   Workbooks.Add
   fileSaveName = ("Friday Communication created by ") & (Employeename) & (" on ") & (Reportdate)
       MsgBox "Save as " & fileSaveName
           If vbOK Then
           ActiveWorkbook.SaveAs Filename:="Y:\Work\" < fileSaveName > ".xls"
           End If

It does save a copy of the file but it saves it as TRUE.xls, clearly I am missing a trick, can you help?

Answer
I think the trick is on the use of parenthesis to concatenate text, the code is doing logical comparisions instead.  Try changing the sentence to:
fileSaveName = "Friday Communication created by " & Employeename & " on " & Reportdate

Hope this helps,
Miguel.

View Follow-Ups    Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.