Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default macro opening a file

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 Whe=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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default macro opening a file

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 Whe=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


"Leon" wrote:

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 Whe=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

Reply
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
Can a macro be run on opening the file? Cortez Excel Discussion (Misc queries) 3 March 8th 07 08:34 PM
Opening a file through a macro - Help!! Matt Excel Programming 5 September 28th 06 04:40 PM
File opening via Macro with varying file name TomFish79 Excel Programming 3 August 15th 05 02:32 PM
Opening a file with a Macro Adam1 Chicago Excel Discussion (Misc queries) 2 February 28th 05 10:13 PM


All times are GMT +1. The time now is 05:17 PM.

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"