+ Reply to Thread
Results 1 to 1 of 1

Read Embedded text file content through Excel VBA

  1. #1
    Registered User
    Join Date
    09-13-2016
    Location
    Atlanta
    MS-Off Ver
    2013 and 2016
    Posts
    1

    Read Embedded text file content through Excel VBA

    For Excel 2013

    I have an req to display records from SQL DB into Excel table. Plan is to Embed SQL Query as Text file in Excel itself so that when user clicks a button, macro appends parameter to it and pass it as
    ActiveWorkbook.Connections("Test1").OLEDBConnection.CommandText = query
    'ActiveWorkbook.Connections("Test1").OLEDBConnection.Refresh

    Q1) How can i read text content from embedded object into String variable to pass as stated above.
    I have seem embedded object is stored in temp folder like C:\users\[username]\AppData\local\Temp\sql(2).txt.
    Q1A) how do i read that file path through code avoiding hardwired.

    Q2) Appreciate alternate suggestion of storing & reading query with below constrains.

    my constraints are
    - Cannot use Database to preserver query and make a call to it (stored proc..)
    - Do not want to store query outside of Excel and read the query into Excel.
    - Query is kind of dynamic in nature and not appropriate to hardwired entirely in cmdText connection properties via GUI for some reason.
    Last edited by mrleokarthik; 09-13-2016 at 04:38 PM. Reason: last line added

+ 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] Import text file content and file name into excel.
    By Hakktu in forum Excel General
    Replies: 3
    Last Post: 09-17-2014, 07:38 AM
  2. To read many text files and write it in the excel file
    By nynamyna in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-16-2009, 01:51 PM
  3. read value of strings from a text file and make an excel file.
    By gashforing in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-08-2009, 07:12 AM
  4. read (XYZ) text file to many sheets in Excel
    By masher in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-12-2009, 02:20 AM
  5. how to Read content or text of cells Named
    By Raju A in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-06-2008, 02:25 PM
  6. Read Text File into Excel Using VBA
    By Willie T in forum Excel General
    Replies: 14
    Last Post: 08-17-2008, 11:04 AM
  7. [SOLVED] How to read text content of AS400 screen
    By abc in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-28-2005, 08:00 PM

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