Home » Infrastructure » Windows » OO4O-Query on text file (Excel VBA / OO4O)
OO4O-Query on text file [message #628957] Mon, 01 December 2014 08:21 Go to next message
oteixeira
Messages: 33
Registered: May 2007
Member
Hello to all,
I'm using OO4O and Excel 2007 on windows 7.
Normally i write my SQL statements whitin the VBA code. Now i have to use an huge query which is not easy to manipulate within the VBA code.
So my question is:
Is there a way of having the query on a text file and calling it from Excel VBA ?

Thank a lot in advance for any kind help.
Octavio
Re: OO4O-Query on text file [message #628958 is a reply to message #628957] Mon, 01 December 2014 08:24 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Problem & solution have nothing to go with Oracle RDBMS
Re: OO4O-Query on text file [message #628959 is a reply to message #628958] Mon, 01 December 2014 08:27 Go to previous messageGo to next message
oteixeira
Messages: 33
Registered: May 2007
Member
Sorry, I tried posting on OO4O questions....Did I use the wrong forum?
If yes can you please re-direct me?
Thank you.
Octavio
Re: OO4O-Query on text file [message #628960 is a reply to message #628957] Mon, 01 December 2014 08:42 Go to previous messageGo to next message
Michel Cadot
Messages: 68042
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

You can "load" your file text into a VBA variable and execute it with OO4O as you use to do it.

Re: OO4O-Query on text file [message #628961 is a reply to message #628960] Mon, 01 December 2014 08:45 Go to previous messageGo to next message
oteixeira
Messages: 33
Registered: May 2007
Member
Michel, thanks a lot for answering but i am not such an expert.
Can you please be so kind and give me some few lines of code of how to "load" the text file into a VBA variable?
Thanks again.
Re: OO4O-Query on text file [message #628962 is a reply to message #628961] Mon, 01 December 2014 08:54 Go to previous messageGo to next message
Michel Cadot
Messages: 68042
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

I didn't write VB since about 10 years so I forgot, I'm pretty sure you can find such code by googling a little bit; try "VBA load a file into a variable".

[Updated on: Mon, 01 December 2014 08:56]

Report message to a moderator

Re: OO4O-Query on text file [message #628963 is a reply to message #628962] Mon, 01 December 2014 08:57 Go to previous messageGo to next message
Michel Cadot
Messages: 68042
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

First hit: http://mrspreadsheets.com/1/post/2013/09/vba-code-snippet-22-read-entire-text-file-into-string-variable.html

Option Explicit
Public g_strVar As String

Sub Test_Proc()

    g_strVar = ImportTextFile("C:\file.txt")
    MsgBox g_strVar

End Sub

Function ImportTextFile(strFile As String) As String

    Open strFile For Input As #1
    ImportTextFile = Input$(LOF(1), 1)
    Close #1

End Function

Re: OO4O-Query on text file [message #628964 is a reply to message #628963] Mon, 01 December 2014 08:58 Go to previous message
oteixeira
Messages: 33
Registered: May 2007
Member
Thanks a million Michel.
Previous Topic: No database operators available
Next Topic: create an oracle dump file
Goto Forum:
  


Current Time: Tue Nov 30 05:39:18 CST 2021