|
-
Nov 24th, 2004, 04:20 PM
#1
Thread Starter
Addicted Member
Date Stamp & Imaging Macro
Hello,
I'm working on a system which saves documents in a particular way. If I am saving a document, I save it in the format YYYY-MM-DD XXXX so, for example, an invoice would be '2004-11-24 Invoice'.
This is fine but it is time consuming & it allows errors to creep in. I
would like to be albe to do something different & I wonder whether you might be able to help me.
When I want to save a document, I'd like to print a copy & to save an image file by printing & saving it to the Microsoft Office Document Image Writer & to prepare to save it as a word document by opening up the Save dialog box, giving the document a name according to the current date & time EG '2004-11-24 16.24' & allowing me to choos where to save it.
Can anybody tell me how I might to this or whether there is a macro available to do something like this for me?
Thanks
Sam
-
Nov 25th, 2004, 01:39 AM
#2
This code I wrote for you will solve your issue of presetting the save
as dialog with a preformatted filename/timestamp. This is a
completely dynamic save as.
Note: this is from within Word's VBA. If you need it to be VB only
let me know. Not too much difference.
VB Code:
Public Function MySaveAs(ByVal sType As String) As Boolean
On Error GoTo No_Bugs
Dim oDLG As Dialog
Dim sFileName As String
sFileName = Format(Now, "yyyy-mm-dd_hh-mm-ss") & " " & sType & ".doc"
Set oDLG = Application.Dialogs(wdDialogFileSaveAs)
With oDLG
.Application.ActiveDocument.SaveAs sFileName
.Update
.Show
End With
If Application.ActiveDocument.Saved = True Then
MySaveAs = True
Else
MySaveAs = False
End If
Exit Function
No_Bugs:
MySaveAs = False
End Function
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|