Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Question about saving a *.dbf file

Windows XP
Excel 2002

I have a bit of code that is supposed to prompt the user for a path and file
name to save their workbook in, but I'm getting an error. The user is
intended to save a single worksheet workbook as a dbf file, and all the
necessary elements are present. Here is the code:

Sub SaveCoordinates()

Dim Filt As String
Dim FilterIndex As Integer
Dim Title As String
Dim FileName As String
Dim InitialFileName As String

FileName = ""

' Set up list of file filters
Filt = "DBF file (*.dbf)"

' Display *.dbf* by default
FilterIndex = 1

' Set the dialog box caption
Title = "Save Coordinates"

' Default File name
InitialFileName = "New_Coord_data"

' Get the file name
FileName = Application.GetSaveAsFilename( _
InitialFileName:=InitialFileName, _
FileFilter:=Filt, _
FilterIndex:=FilterIndex, _
Title:=Title)

Application.DisplayAlerts = False
ActiveWorkbook.SaveAs FileName:=FileName
Application.DisplayAlerts = True

End Sub


So, could someone kindly tell me what is wrong with the above code?

Any help greatly appreciated - thanks!

-gk-


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Question about saving a *.dbf file

Hi 39N95W
You'll need to change the filter conditions to the following.....

Filt = "DBF file (*.dbf), .dbf"

extract from VBA help.....
This string consists of pairs of file filter strings followed by the MS-DOS
wildcard file filter specification, with each part and each pair separated
by commas. Each separate pair is listed in the Files of type drop-down list
box. For example, the following string specifies two file filters, text and
addin: "Text Files (*.txt), *.txt, Add-In Files (*.xla), *.xla".

Cheers
Nigel

"39N95W" wrote in message
...
Windows XP
Excel 2002

I have a bit of code that is supposed to prompt the user for a path and

file
name to save their workbook in, but I'm getting an error. The user is
intended to save a single worksheet workbook as a dbf file, and all the
necessary elements are present. Here is the code:

Sub SaveCoordinates()

Dim Filt As String
Dim FilterIndex As Integer
Dim Title As String
Dim FileName As String
Dim InitialFileName As String

FileName = ""

' Set up list of file filters
Filt = "DBF file (*.dbf)"

' Display *.dbf* by default
FilterIndex = 1

' Set the dialog box caption
Title = "Save Coordinates"

' Default File name
InitialFileName = "New_Coord_data"

' Get the file name
FileName = Application.GetSaveAsFilename( _
InitialFileName:=InitialFileName, _
FileFilter:=Filt, _
FilterIndex:=FilterIndex, _
Title:=Title)

Application.DisplayAlerts = False
ActiveWorkbook.SaveAs FileName:=FileName
Application.DisplayAlerts = True

End Sub


So, could someone kindly tell me what is wrong with the above code?

Any help greatly appreciated - thanks!

-gk-




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Question about saving a *.dbf file

39N95W

Change this line of code

Filt = "DBF file (*.dbf)"

to

Filt = "DBF file (*.dbf), *.dbf"

Tested on Excel 9

--
Message posted from http://www.ExcelForum.com

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
Question on saving a file. Crissyb Excel Discussion (Misc queries) 5 February 12th 10 06:45 PM
Saving Excel 2007 file in 2003 creates very large file Jon Pearce Excel Discussion (Misc queries) 2 July 16th 09 07:20 PM
Confused here Prevent Saving File - but allow ONLY File SAVEAS Met JMay Excel Discussion (Misc queries) 2 June 17th 07 04:37 PM
Saving worksheet in new file with date AND cell value as file name michaelberrier Excel Discussion (Misc queries) 4 May 26th 06 08:05 PM
How do I stop Excel 2000 from saving file history from file that . Cathy Excel Discussion (Misc queries) 0 March 29th 05 03:27 PM


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