Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Preventing FALSE.xls when automating SaveAs


For the type of work I do, I must lock down Excel spreadsheets for legal
and risk reasons. We try to automate the spreadsheets as much as
possible, and the main focus on current work is save and send
functionality.

I have that working perfectly - including the generation of
filename/subjectline through either specified information in a setInfo
procedure or derived from information input by users.

However, when the user launches a save and send routine, if they cancel
the save procedure (which is required for the send routine) it produces
the FALSE.xls file.

Has anyone figured out how to prevent this?


--
ljsmith
------------------------------------------------------------------------
ljsmith's Profile: http://www.excelforum.com/member.php...o&userid=30531
View this thread: http://www.excelforum.com/showthread...hreadid=501828

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Preventing FALSE.xls when automating SaveAs

I assume you're using GetSaveAsFileName. The variable that
receives the result of GetSaveAsFilename should be declare as
Variant not String.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"ljsmith"
wrote in message
...

For the type of work I do, I must lock down Excel spreadsheets
for legal
and risk reasons. We try to automate the spreadsheets as much
as
possible, and the main focus on current work is save and send
functionality.

I have that working perfectly - including the generation of
filename/subjectline through either specified information in a
setInfo
procedure or derived from information input by users.

However, when the user launches a save and send routine, if
they cancel
the save procedure (which is required for the send routine) it
produces
the FALSE.xls file.

Has anyone figured out how to prevent this?


--
ljsmith
------------------------------------------------------------------------
ljsmith's Profile:
http://www.excelforum.com/member.php...o&userid=30531
View this thread:
http://www.excelforum.com/showthread...hreadid=501828



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Preventing FALSE.xls when automating SaveAs


That may be the ticket.

fileSaveName = Application.GetSaveAsFilename( _
fileName & ".xls", fileFilter:="Microsoft Excel Workbook (*.xls),
*.xls")

is the code I'm using, both fileName and fileSaveName are listed as
strings.

If I'm following what you're saying, it should be:

dim fileSaveName as Variant

rather than

dim fileSaveName as String

Correct?

Or should it be:

dim fileName as Variant

rather than

dim fileName as String


--
ljsmith


------------------------------------------------------------------------
ljsmith's Profile: http://www.excelforum.com/member.php...o&userid=30531
View this thread: http://www.excelforum.com/showthread...hreadid=501828

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Preventing FALSE.xls when automating SaveAs

Dim FileSaveName as variant
filesavename = application.getsaveasfilename(....)

if filesavename = false then
'user hit cancel
exit sub
end if

'otherwise, keep going:
activeworkbook.saveas filename:=filesaveasname

ljsmith wrote:

That may be the ticket.

fileSaveName = Application.GetSaveAsFilename( _
fileName & ".xls", fileFilter:="Microsoft Excel Workbook (*.xls),
*.xls")

is the code I'm using, both fileName and fileSaveName are listed as
strings.

If I'm following what you're saying, it should be:

dim fileSaveName as Variant

rather than

dim fileSaveName as String

Correct?

Or should it be:

dim fileName as Variant

rather than

dim fileName as String

--
ljsmith

------------------------------------------------------------------------
ljsmith's Profile: http://www.excelforum.com/member.php...o&userid=30531
View this thread: http://www.excelforum.com/showthread...hreadid=501828


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Preventing FALSE.xls when automating SaveAs

That's correct, the variable should be a Variant. Then you can
check to see if it is False (not "False") and act accordingly.
E.g.,

fileSaveName = Application.GetSaveAsFilename( _
fileName & ".xls", fileFilter:="Microsoft Excel Workbook
(*.xls),*.xls")
If fileSaveName = False Then
' user cancelled
Else
msgbox fileSaveName
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"ljsmith"
wrote in message
...

That may be the ticket.

fileSaveName = Application.GetSaveAsFilename( _
fileName & ".xls", fileFilter:="Microsoft Excel Workbook
(*.xls),
*.xls")

is the code I'm using, both fileName and fileSaveName are
listed as
strings.

If I'm following what you're saying, it should be:

dim fileSaveName as Variant

rather than

dim fileSaveName as String

Correct?

Or should it be:

dim fileName as Variant

rather than

dim fileName as String


--
ljsmith


------------------------------------------------------------------------
ljsmith's Profile:
http://www.excelforum.com/member.php...o&userid=30531
View this thread:
http://www.excelforum.com/showthread...hreadid=501828





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Preventing FALSE.xls when automating SaveAs


Chip Pearson Wrote:
That's correct, the variable should be a Variant. Then you can
check to see if it is False (not "False") and act accordingly.
E.g.,

fileSaveName = Application.GetSaveAsFilename( _
fileName & ".xls", fileFilter:="Microsoft Excel Workbook
(*.xls),*.xls")
If fileSaveName = False Then
' user cancelled
Else
msgbox fileSaveName
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


Thank you! That worked perfectly. You have no idea how long I've been
trying to solve that problem.


--
ljsmith


------------------------------------------------------------------------
ljsmith's Profile: http://www.excelforum.com/member.php...o&userid=30531
View this thread: http://www.excelforum.com/showthread...hreadid=501828

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Preventing FALSE.xls when automating SaveAs


if it helps - here is the code for that subroutine.

Public Sub saveWkBook()
Dim fileSaveName As String

On Error GoTo ErrorHandler

Call setInfo

' this structures the filename that will be given to the saved
file
If langChoice = "English" Then
fileName = "9868 - " & reqType & " " & myDate
ElseIf langChoice = "French" Then
fileName = "9868F - " & reqType & " " & myDate
End If

' this opens the Save As window and sets the filename and file
type
fileSaveName = Application.GetSaveAsFilename( _
fileName & ".xls", fileFilter:="Microsoft Excel Workbook (*.xls),
*.xls")

' this saves the workbook
ActiveWorkbook.SaveAs fileName:=fileSaveName, FileFormat:=xlNormal
' this generates the messagebox saying the file has been saved.
If langChoice = "English" Then
MsgBox "Saved as " & fileName
ElseIf langChoice = "French" Then
MsgBox "Enregistré sous " & fileName
End If
Exit Sub

ErrorHandler:
Exit Sub
End Sub

(Yeppers - I'm Canadian and deal with language switches too)


--
ljsmith


------------------------------------------------------------------------
ljsmith's Profile: http://www.excelforum.com/member.php...o&userid=30531
View this thread: http://www.excelforum.com/showthread...hreadid=501828

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
Preventing tofimoon3 via OfficeKB.com New Users to Excel 4 February 20th 09 06:03 PM
What's the best way to toggle between true and false in Excel? Hiall, My excel work involves a lot of toggling between true and false (booleantypes) ... and it's very repetitive... Is there a way to select a bunch ofcells, and press a key short-cu LunaMoon Excel Discussion (Misc queries) 9 July 29th 08 12:28 AM
$C$1972,2,FALSE, $C$1972,3,FALSE is ok, But $C$1972,4,FALSE Give # Steved Excel Worksheet Functions 6 July 3rd 06 01:49 AM
Data Validation preventing ISTEXT() from reading FALSE in '97 Adam Kroger Excel Discussion (Misc queries) 2 November 28th 05 12:34 PM
True Or False, no matter what... it still displays the false statement rocky640[_2_] Excel Programming 2 May 13th 04 04:57 PM


All times are GMT +1. The time now is 09:42 AM.

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"