Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9137941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:11:32+00:00 2026-06-17T09:11:32+00:00

I have the following code in an excel macro. All I need to do

  • 0

I have the following code in an excel macro. All I need to do is put a space between my string and the date string that comes out of the format however, I get only the string part if I remove the string I get only the date obviously.

filenamestring = "CMC_Rates " & Format(Now(), "yyyymmdd")

any ideas?

Here’s more code

Dim filenamestring As String
Dim location As String
Dim passparam As String


location = Year(DateTime.Now) & "/" & Month(DateTime.Now)


filenamestring = "CMC_Rates " & Format(Now(), "yyyymmdd ") & Format(Range("EffTime").Value, "hhmm AMPM") & ".pdf"




passparam = location & "/" & filenamestring

Call Shell(Environ$("COMSPEC") & " /c \\atlanta2-0\MKTG\Rates\SaveFile.bat " & filenamestring, vbNormalFocus)

SaveFile.bat has this in it

pscp -batch -pw password filename.xlsx admin@172.17.1.5:/Path/%1

When it opens the bat it says the paramater is just CMC_Rates, however if I take out the space and put it all together it works.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:11:32+00:00Added an answer on June 17, 2026 at 9:11 am

    the problem is with this line: (split for readability)

    Call Shell(Environ$("COMSPEC") _
      & " /c \\atlanta2-0\MKTG\Rates\SaveFile.bat " _
      & filenamestring, vbNormalFocus)
    

    when Excel calls your batch file, the COMSPEC interpreter treats the filename as more than one argument, as spaces are used as separators. To indicate the filename is one argument, and not many, it needs to be enclosed in quotes “

    This will change the line to this:

    Call Shell(Environ$("COMSPEC") _
      & " /c \\atlanta2-0\MKTG\Rates\SaveFile.bat " _
      & chr(34) & filenamestring & chr(34), vbNormalFocus)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code in my Excel VBA that copies data from a
I have the following VBA code inside an Excel macro: With ActiveSheet.QueryTables.Add( _ Connection:=ConnStr,
I am have the following code for excel vba that will email a range
I have an Excel macro that is copying all of the information from a
I have the following code: private bool IsMousetrapFile(string path) { logger.Log(validateFileMessage + path); Excel.Application
I'm doing a small app in Excel, and I have the following code when
I have following code for updating user's column public void UpdateLastModifiedDate(string username) { using
I have following code that I am compiling in a .NET 4.0 project namespace
I have an excel template that uses a macro to save the file, so
I have the following code to export a gridview to excel and the export

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.