PC Review


Reply
Thread Tools Rate Thread

Dialogbox VBA

 
 
simon.frangenberg@montesquieu.nl
Guest
Posts: n/a
 
      18th Aug 2008
I am Working on the following code:

Dim resp As Long
Dim sFilename As Variant
Dim newName As String

newName = "I:\Klant Directory\book1.xls"

sFilename = Application.GetSaveAsFilename( _
InitialFileName:=newName)
If sFilename = False Then Exit Sub

If Dir(sFilename) <> "" Then
resp = MsgBox(prompt:="File already exists. Do you want to
overwrite?", Buttons:=vbYesNo)
If resp = vbNo Then
Exit Sub
End If
End If

Application.DisplayAlerts = False
ActiveWorkbook.SaveAs sFilename
Application.DisplayAlerts = True


Instead of book1; I want to save excel files in the following format:
subject-client-date-author (e.g. Report-Vbacorp-20080818-MF).
Furthermore, if I run the macro, I want to have a dialogbox that pups
up with date and author already filled out as in the above mentioned
example (thus: now() and MF). Moreover, I want to be able to fill out
in the dialog box the subject and client. Dialog box example:

Subject:
Client:
Date: default format(now(),”yyyymmdd”)
Author: default MF

Save Cancel

I do not know how to fix the code above in order to achieve this, doe
anyone have a clue?
 
Reply With Quote
 
 
 
 
strive4peace
Guest
Posts: n/a
 
      18th Aug 2008
Hi Simon,

this is an Access forum -- seems like you have an Excel question ...

but, to give you some food for thought ...

if you want the file to be called something other than Book1, then you
need to change your code to construct the filename. You can do
something like this:

Dim file_path As String
Dim file_name As String

file_path = "I:\Klant Directory\"

file_name = "Report-Vbacorp-" _
& format(Date(), "yyyymmdd") & "-MF" _
& ".xls"

then you can do this:

file_path & file_name

to reference the full file specification

just as the date can be concatenated in, so can the other values for
subject, client, and author

if these values are stored in cells, you can reference them -- but
please, if you are doing this in Excel, ask this question in an Excel
newsgroup


Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
(: have an awesome day
*




(E-Mail Removed) wrote:
> I am Working on the following code:
>
> Dim resp As Long
> Dim sFilename As Variant
> Dim newName As String
>
> newName = "I:\Klant Directory\book1.xls"
>
> sFilename = Application.GetSaveAsFilename( _
> InitialFileName:=newName)
> If sFilename = False Then Exit Sub
>
> If Dir(sFilename) <> "" Then
> resp = MsgBox(prompt:="File already exists. Do you want to
> overwrite?", Buttons:=vbYesNo)
> If resp = vbNo Then
> Exit Sub
> End If
> End If
>
> Application.DisplayAlerts = False
> ActiveWorkbook.SaveAs sFilename
> Application.DisplayAlerts = True
>
>
> Instead of book1; I want to save excel files in the following format:
> subject-client-date-author (e.g. Report-Vbacorp-20080818-MF).
> Furthermore, if I run the macro, I want to have a dialogbox that pups
> up with date and author already filled out as in the above mentioned
> example (thus: now() and MF). Moreover, I want to be able to fill out
> in the dialog box the subject and client. Dialog box example:
>
> Subject:
> Client:
> Date: default format(now(),”yyyymmdd”)
> Author: default MF
>
> Save Cancel
>
> I do not know how to fix the code above in order to achieve this, doe
> anyone have a clue?

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dialogBox Michael Sgier Microsoft Dot NET Framework Forms 2 20th Apr 2006 04:08 PM
DialogBox Layout Patrick Simonds Microsoft Excel Programming 2 1st Oct 2005 09:35 PM
VC++.Net DialogBox foreman Microsoft VC .NET 1 6th Mar 2005 10:32 AM
dialogbox ? Chris Microsoft ASP .NET 2 25th Apr 2004 05:02 PM
DialogBox Greg Microsoft Excel Programming 2 17th Sep 2003 01:41 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:00 AM.