+ Reply to Thread
Results 1 to 2 of 2

Macro that will insert a simple text string in top cell of text file

  1. #1
    Registered User
    Join Date
    10-25-2014
    Location
    Nashville TN
    MS-Off Ver
    2010
    Posts
    4

    Macro that will insert a simple text string in top cell of text file

    I am building a macro in Access but i have hit a snag since fields cannot be titled more than 64 characters. So now I need to come up with some VBA that will simply insert text into cell A1 of a closed file.

    I need for the top right cell (i.e., Cell A1) to read:

    "Action (SiteID=US|Country=US|Currency=USD|ListingType=Half|Location=US|ListingDuration=GTC)"

    I am hoping to build a separate macro that will insert the below text in cell A1 of this file. The file it titled: 007_HalfFileAV2.txt. I can either delete and paste over the existing text in cell A1 (which shows the truncated first 64 characters, i.e., "Action (SiteID=US|Country=US|Currency=USD|ListingType=Half|Locat", or I can add the missing "ion=US|ListingDuration=GTC)" to the end of the truncated text.....whichever is easier.

    Is there some straightforward VBA code that I can add to an excel workbook that will accomplish this? I don't have VBA experience with Access but that would be another option. Thanks for any direction, code, etc that you can provide.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: Macro that will insert a simple text string in top cell of text file

    Text files don't have cells. In order to pre-pend a header row, you'd need to read the whole text file into a variable, close the text file, edit the variable, open the text file for output and write the variable to the file.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ 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. [SOLVED] Find partial text string within another text string return original text into cell.
    By mikey42979 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-17-2013, 02:58 PM
  2. [SOLVED] Macro to Insert copy of Row based on text String
    By j2591 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-28-2013, 09:32 AM
  3. [SOLVED] Insert a NAME into a text string in a single cell
    By cptkeith in forum Excel General
    Replies: 1
    Last Post: 12-17-2012, 06:04 PM
  4. Insert Row macro based on text String
    By georgeanaprop in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-20-2009, 03:29 AM
  5. Replies: 1
    Last Post: 05-31-2005, 10:18 AM

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