LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #17   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Function to read text file; find string; delete same before import

You can't compile into a dll with VBA, but I believe with FreeBasic you can
and it is free.
Must admit though I have never done it as I have VB6.

RBS


wrote in message
...
I guess I do not appreciate the relative cost issues. All I want to do is
compile my VBA code into
a DLL. It is quite possible that $600 is worth it.

"RB Smissaert" wrote:

Even at $600 you will find it money well spent.
Another option might be FreeBasic:
http://www.freebasic.net/

RBS


wrote in message
. ..

In your reply you commented "if you have the stand-alone (compiled)
Visual
Basic program available
(Version 6 only because of the use of the Replace function." This
reminded me of compiling "macro
project" into a .DLL which is much more "secure" than a VBProject
password; at least that is what I
heard.

All that said, I cheched the price for VB6, about $600, and read that it
is essentially orphaned
(not sold by MS) in favor of .NET.

Are there any alternate choices to secure VBA?

TIA EagleOne


"Rick Rothstein \(MVP - VB\)"
wrote:

I'm not sure I understand what your "'secure' the code" concerns are...
what
part of the process is it that you are worried about, what part do you
think
needs to be secured?

Rick


wrote in message
m...
Rick,

Is it necessary (the only way) to VB6-compile a DLL to call from a
macro
to "secure" the code?

If so, I'll purchase VB6 just for that purpose.

I assume the following steps?:

1) write the VBA procedure(s)
2) load VB6
3) perform 1,2,3,4 steps in VB6
4) out pops a DLL.
5) refer to the DLL in my macro
6) (whatever I missed)

Would you BRIEFLY (being sensitive to your time) expand upon #3 & #5?

EagleOne

"Rick Rothstein \(MVP - VB\)"
wrote:

FreeFile is a function built into VB, so you do not have to do
anything
special to use it... it is automatically available. By the way, the
code
I
posted will work, as posted, within Excel as a macro... if you have
the
stand-alone (compiled) Visual Basic program available (Version 6 only
because of the use of the Replace function), then the subroutine I
posted
can be run from inside a VB6 program exactly as written and it will
work
in
that environment too.

Rick


wrote in message
news:49o894pfvsg0rlq8ofp5k814hpuih66edn@4ax. com...
Rick, having solutions bith inside and outside is Excel excellent!

I looked up FreeFile and found it as a Function. Is FreeFile a
function
available by reference to
the "typical" Excel and/or typical-install Visual Basic Libraries or
should one grab the FreeFall
function and place it in one's VBA module?


"Rick Rothstein \(MVP - VB\)"
wrote:

Your file is not too large to do with a macro in Excel (just change
the
path
and filename assignment to your own file's path and name)...

Sub GetDataOnly()
Dim FileNum As Long
Dim FileName As String
Dim TotalFile As String

FileName = "c:\Path\To\File\MyFile.txt"

FileNum = FreeFile
Open FileName For Binary As #FileNum
TotalFile = Space(LOF(FileNum))
Get #FileNum, , TotalFile
Close #FileNum
TotalFile = replace(TotalFile, "SELECT TO_CHAR(NET" & vbCrLf & _
"AMT|DOC_NUM|FIPC|" & vbCrLf, "")
TotalFile = replace(TotalFile, "REPORT COMPLETE", "")
FileNum = FreeFile
Open FileName For Output As #FileNum
Print #FileNum, TotalFile
Close #FileNum
End Sub

Rick


wrote in message
news:4ha794h95idlgkbvj95dqj8cu4ih8eaifb@4a x.com...
Thank you for taking your time and for your knowledge.

I guess I should have been more clear.

The import itself is not the issue. What I was looking for is a
function
that would:
1) read an entire text file line by line
2) find each and every line with an instance of:
SELECT TO_CHAR(NET (and/or)
AMT|DOC_NUM|FIPC| (and/or)
REPORT COMPLETE (and/or)
3) delete the entire line(s)
4) leaving only the pure data
5) save the file
6) (then import into Excel about which I do not need assistance)

In short, I want the file to contain only:

407.44|N6887008TORHMS5|D|22|AA|08|
2500.00|N6887008MDNC018|D|36|AA|08|
-2500.00|N6887008MDNC013|D|36|AA|08|
2133.18|N6887008MDNC013|D|36|AA|08
-1004.93|N6887008WR82003|D|36|AA|08|
407.44|N6887008TORHMS5|D|22|AA|08|
2500.00|N6887008MDNC018|D|36|AA|08|
-2500.00|N6887008MDNC013|D|36|AA|08|
2133.18|N6887008MDNC013|D|36|AA|08

EagleOne

Joel wrote:

This is very simple. I don't know what you are refering to when
you
mean
FIND STRING since everything is a string in the TEXT file. It is
also
important to know wher each line ends. Not sure if your code
exactly
represents the text file. Open the file with Notepad and make
sure
WORD
WRAP
(Format menu) is NOT checked. Then lok at text file and let me
know
where
the end of each line is located.

I have two methods of doing this task. I can import the file and
then
make
the changes in excel to delete the data you don't want. Or make
the
changes
before I put the data into spreadsheet.

If you want to try a quick experiment try to impor the dat
manually.

From worksheet menue
1) Data - Import External Data - Import Data
2) Press Delimited - Next
3) Uncheck everything except Other and put the | in the box next
to
Other
4) Press finish and select where you want the data to go.

You can also turn on Record Macro before you do these operations
to
get
a
macro.

" wrote:

2003

Need a VBA function to read text file; find string; delete same
before
import.

The function should find all instances (there can be many) of:
SELECT TO_CHAR(NET
AMT|DOC_NUM|FIPC|

the last line of the file

REPORT COMPLETE

In short, just the data please

SELECT TO_CHAR(NET
AMT|DOC_NUM|FIPC|
407.44|N6887008TORHMS5|D|22|AA|08|
2500.00|N6887008MDNC018|D|36|AA|08|
-2500.00|N6887008MDNC013|D|36|AA|08|
2133.18|N6887008MDNC013|D|36|AA|08
-1004.93|N6887008WR82003|D|36|AA|08|
SELECT TO_CHAR(NET
AMT|DOC_NUM|FIPC|
407.44|N6887008TORHMS5|D|22|AA|08|
2500.00|N6887008MDNC018|D|36|AA|08|
-2500.00|N6887008MDNC013|D|36|AA|08|
2133.18|N6887008MDNC013|D|36|AA|08
-1004.93|N6887008WR82003|D|36|AA|08|
REPORT COMPLETE

TIA any and all help greatly appreciated


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find Text File Import Cell ExcelMonkey Excel Programming 4 August 8th 05 02:43 PM
How to import a text file to Excel treating all input content are in string. Chittu Excel Discussion (Misc queries) 1 July 22nd 05 06:37 AM
Import partial record from text file string goss[_37_] Excel Programming 1 November 16th 04 07:38 PM
Import partial record from text file string goss[_36_] Excel Programming 1 November 16th 04 03:45 AM
backwards find function to find character in a string of text Ashleigh K. Excel Programming 1 January 14th 04 04:36 PM


All times are GMT +1. The time now is 08:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"