+ Reply to Thread
Results 1 to 3 of 3

VBA Code to Name a File with Dim as String

  1. #1
    Forum Contributor
    Join Date
    12-09-2015
    Location
    Virginia, USA
    MS-Off Ver
    2007
    Posts
    121

    VBA Code to Name a File with Dim as String

    Hello,

    I know I'm missing something simple, but I am struggling to figure out what is wrong...a little rusty!

    B16 = c:/csv/


    Please Login or Register  to view this content.
    When I try to run my macro and it makes it to the save function above, it croaks on the following error:


    <b>Run Time Error 1004: The file could not be accessed for one of the following reasons.</b>

    It then lists a bunch of reasons, but none of them apply.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA Code to Name a File with Dim as String

    Looks like you have the path separators the wrong way round

    Try \ instead of / in B16
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Contributor
    Join Date
    12-09-2015
    Location
    Virginia, USA
    MS-Off Ver
    2007
    Posts
    121

    Re: VBA Code to Name a File with Dim as String

    Wow. That was easy! Thank you!

    I wonder why it was able to import a file using that directory format but it couldn't save?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 7
    Last Post: 02-07-2020, 05:17 AM
  2. Save a (binary) file as string in code and write to disk when needed.
    By JasperD in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-06-2019, 08:54 AM
  3. [SOLVED] Attachments : Save and Rename using Sublect string or File name string
    By checksamir in forum Outlook Programming / VBA / Macros
    Replies: 4
    Last Post: 11-13-2014, 01:13 AM
  4. [SOLVED] MACRO: Store name of selected file as string w/ import data file dialog box
    By AnnieMcken in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-13-2013, 02:13 PM
  5. [SOLVED] Need code to pull numeric data out of an alphanumeric string (string not constant)
    By harrydnyc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-09-2013, 04:44 PM
  6. Replies: 1
    Last Post: 08-04-2009, 06:42 AM
  7. Code to locate string or enter a new string with corresponding value
    By Yappa in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-18-2008, 07:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1