Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

Can someone convert this Excel macro code into a VB code to skip use of Excel program ?


This topic is 6602 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

First of all tx in advance for reading this post. I'm not a programmer at all, so I even don't know if I'm asking to do this in the wright coding language:

In essence this my project }:|

I have a .log file that I need to convert structuraly to make it

usefull in FileMaker.

- open the logfile

- In the .log file there is a character that needs to be replaced with

another, to be able to convert it more easely into colums.

- Delete colums the Second and Forth colum (in excel since the shift

places it is first B, than C)

- Then those colums needs to be transposed (rows becomes colums) in order to be able to import them into FileMaker.

- save the logfile

I can do this in Excel but I want to skip the use of Excel. I only like

to use FM because it is going to be a runtime application. My costumers

wont have a 'full version' of FM and may or may not have Excel.

running FM pro 8.5 on Win XP.

Kind regards and Tx in advance !!!!

___________________________________

Option Explicit

Sub ReplaceAndTranspose()

Dim FromChars As Variant

Dim ToChars As Variant

Dim iCtr As Long

FromChars = Array(Chr(28))

ToChars = Array(Chr(124))

If UBound(FromChars) <> UBound(ToChars) Then

MsgBox "design error--make from/to match"

Exit Sub

End If

For iCtr = LBound(FromChars) To UBound(FromChars)

ActiveSheet.Cells.replace What:=FromChars(iCtr), _

Replacement:=ToChars(iCtr), LookAt:=xlPart, _

SearchOrder:=xlByRows, MatchCase:=False

Next iCtr

Columns("A:A").Select

Selection.TextToColumns Destination:=Range("A1"),

DataType:=xlDelimited, _

TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False,

Tab:=False, _

Semicolon:=False, Comma:=False, Space:=False, Other:=True,

OtherChar _

:="|", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1),

Array(4, 1), Array(5, _

1)), TrailingMinusNumbers:=True

Cells.Select

Cells.EntireColumn.AutoFit

Columns("B:B").Select

Selection.Delete Shift:=xlToLeft

Columns("C:C").Select

Selection.Delete Shift:=xlToLeft

Cells.Select

With Selection

.HorizontalAlignment = xlLeft

.VerticalAlignment = xlBottom

.WrapText = False

.Orientation = 0

.AddIndent = False

.IndentLevel = 0

.ShrinkToFit = False

.ReadingOrder = xlContext

.MergeCells = False

End With

Range("A1:B200").Select

Selection.Copy

Sheets.Add

Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,

SkipBlanks:= _

False, Transpose:=True

Application.CutCopyMode = False

ActiveWorkbook.Save

End Sub

Posted

I don't think I'm fully understanding what you are asking.

FileMaker can handle an Excel file in several ways:

FileMaker can open an Excel file direct.

FileMaker can import an Excel File into an existing FileMaker File.

Excel can save a file as text which FileMaker can import.

If this doesn't cover it, or you have tried them and it still isn't working, try attaching a copy of the Excel file so we can see the data.

If I have missed your question, please let me know.

HTH

LEe

Posted

Hello there, tx for replying.

Yes I know that I can import/open an excelfile into FM. And yes I know that excel can convert into a txt file.

This last one is exactly what I do today. I have a log file wich is 'unusable' as it is, open it in excel apply the macro (from my post) and then finally let FM import that modified txt file.

But I read somewhere that minor changes like I do on my log/txt file could maybe be done without the use of excel, just by proper coding in some language.

And that is what I'm looking after }:| cause my clients may or may not have excel on there machines. Modify my log thru coding (which change it into a proper txtfile) which FM can import.

to synthesise : a button with some code behind that does exactly what excel does but without the use excel.

Kind regards

This topic is 6602 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.