Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I add a File Open box to this script???

The Basic Script below was captured using Excels "Record Macro"
feature. As recorded, it opens the file: "TEXT;P:\WB Test\Aspen Sample
Mail Files\020604\mailing\new\SBELECPRD_9111140388.SPF; 1" and performs
a series of actions on the file.

Instead of opening a specific file I would like this macro to instead
launch an "Open File" Dialog box to allow me to specify which file
will be processed.

Can anyone tell me how to add the "Open File" dialog to this macro?

Best Regards,

Marcel




Sub Process_Aspen_Mail_File()
'
' Process_Aspen_Mail_File Macro
' Macro recorded 2/5/2004 by preprint
'

'
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;P:\WB Test\Aspen Sample Mail
Files\020604\mailing\new\SBELECPRD_9111140388.SPF; 1" _
, Destination:=Range("A1"))
.Name = "SBELECPRD_9111140388.SPF;1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = True
.TextFileColumnDataTypes = Array(2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2)
.Refresh BackgroundQuery:=False
End With
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default How do I add a File Open box to this script???

Marcel,

Try something like

Dim FName As Variant
FName = Application.GetOpenFilename()
If FName = False Then
' no file choses
Else
' open FName
End If



"maleemi" wrote in message
om...
The Basic Script below was captured using Excels "Record Macro"
feature. As recorded, it opens the file: "TEXT;P:\WB Test\Aspen

Sample
Mail Files\020604\mailing\new\SBELECPRD_9111140388.SPF; 1" and

performs
a series of actions on the file.

Instead of opening a specific file I would like this macro to

instead
launch an "Open File" Dialog box to allow me to specify which

file
will be processed.

Can anyone tell me how to add the "Open File" dialog to this

macro?

Best Regards,

Marcel




Sub Process_Aspen_Mail_File()
'
' Process_Aspen_Mail_File Macro
' Macro recorded 2/5/2004 by preprint
'

'
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;P:\WB Test\Aspen Sample Mail
Files\020604\mailing\new\SBELECPRD_9111140388.SPF; 1" _
, Destination:=Range("A1"))
.Name = "SBELECPRD_9111140388.SPF;1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = True
.TextFileColumnDataTypes = Array(2, 2, 2, 2, 2, 2, 2,

2, 2, 2,
2, 2, 2, 2, 2, 2)
.Refresh BackgroundQuery:=False
End With



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default How do I add a File Open box to this script???

Look at GetOpenFileName in VBA Help.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"maleemi" wrote in message
om...
The Basic Script below was captured using Excels "Record Macro"
feature. As recorded, it opens the file: "TEXT;P:\WB Test\Aspen Sample
Mail Files\020604\mailing\new\SBELECPRD_9111140388.SPF; 1" and performs
a series of actions on the file.

Instead of opening a specific file I would like this macro to instead
launch an "Open File" Dialog box to allow me to specify which file
will be processed.

Can anyone tell me how to add the "Open File" dialog to this macro?

Best Regards,

Marcel




Sub Process_Aspen_Mail_File()
'
' Process_Aspen_Mail_File Macro
' Macro recorded 2/5/2004 by preprint
'

'
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;P:\WB Test\Aspen Sample Mail
Files\020604\mailing\new\SBELECPRD_9111140388.SPF; 1" _
, Destination:=Range("A1"))
.Name = "SBELECPRD_9111140388.SPF;1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = True
.TextFileColumnDataTypes = Array(2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2)
.Refresh BackgroundQuery:=False
End With



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default How do I add a File Open box to this script???

Perhaps you're after something like:

Sub test()
Dim strFile As String

strFile = Application.GetOpenFilename("SPF Files (*.spf), *.spf")
End Sub


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"maleemi" wrote in message
om...
The Basic Script below was captured using Excels "Record Macro"
feature. As recorded, it opens the file: "TEXT;P:\WB Test\Aspen Sample
Mail Files\020604\mailing\new\SBELECPRD_9111140388.SPF; 1" and performs
a series of actions on the file.

Instead of opening a specific file I would like this macro to instead
launch an "Open File" Dialog box to allow me to specify which file
will be processed.

Can anyone tell me how to add the "Open File" dialog to this macro?

Best Regards,

Marcel




Sub Process_Aspen_Mail_File()
'
' Process_Aspen_Mail_File Macro
' Macro recorded 2/5/2004 by preprint
'

'
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;P:\WB Test\Aspen Sample Mail
Files\020604\mailing\new\SBELECPRD_9111140388.SPF; 1" _
, Destination:=Range("A1"))
.Name = "SBELECPRD_9111140388.SPF;1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = True
.TextFileColumnDataTypes = Array(2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2)
.Refresh BackgroundQuery:=False
End With



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
what would the script look like to open a new sheet des-sa[_2_] Excel Discussion (Misc queries) 1 July 16th 08 06:47 PM
How to do something in an VBS script for all worksheets of an Excel file? Claudia d'Amato Excel Discussion (Misc queries) 9 June 26th 08 10:53 PM
simple vb script to open, refina Excel Discussion (Misc queries) 0 June 14th 08 07:37 PM
Script to save Excel file to the server. raj41977 Excel Discussion (Misc queries) 3 December 8th 05 02:48 PM
Create an .xls file by script Mark Powell Excel Programming 0 August 14th 03 11:54 PM


All times are GMT +1. The time now is 04:09 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"