macro opening a file

G

Guest

Hello, I want a macro to pause to select manually a file, and then format it.
I have attached macro, how to modify it?
' Controller_Openen_decimale_punt Macro
' Macro recorded 7/4/2007 by CROMMENTUIJN Leon
'

'
ChDir "C:"
Workbooks.OpenText Filename:="C:\Emerson\log.htm", Origin:=437, StartRow _
:=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1), Array(8,
1), Array( _
14, 1), Array(15, 1)), TrailingMinusNumbers:=True
Columns("C:C").Select
Selection.Delete Shift:=xlToLeft
Columns("A:C").Select
Range("C1").Activate
Charts.Add
ActiveChart.ChartType = xlLine
ActiveChart.SetSourceData Source:=Sheets("log").Range("A1:C192"),
PlotBy:= _
xlColumns
ActiveChart.Location Where:=xlLocationAsNewSheet
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Temperatuurverloop"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "[C]"
.Axes(xlValue, xlPrimary).HasTitle = False
End With
End Sub
 
G

Guest

Use GetOpenFileName Method

Sub test1()

fileToOpen = Application _
.GetOpenFilename("Text Files (*.txt), *.txt")

If fileToOpen <> False Then
Workbooks.OpenText Filename:=fileToOpen, _
Origin:=437, _
StartRow:=1, _
DataType:=xlFixedWidth, _
FieldInfo:= _
Array(Array(0, 1), Array(8, 1), Array(14, 1), Array(15, 1)), _
TrailingMinusNumbers:=True

Columns("C:C").Select
Selection.Delete Shift:=xlToLeft
Columns("A:C").Select
Range("C1").Activate
Charts.Add
ActiveChart.ChartType = xlLine
ActiveChart.SetSourceData _
Source:=Sheets("log").Range("A1:C192"), _
PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsNewSheet

With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Temperatuurverloop"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "[C]"
.Axes(xlValue, xlPrimary).HasTitle = False
End With
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top