Results 1 to 2 of 2

Thread: Date Stamp & Imaging Macro

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2002
    Location
    Leicester, England (City of Kings)
    Posts
    156

    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

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    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:
    1. Public Function MySaveAs(ByVal sType As String) As Boolean
    2.    
    3.     On Error GoTo No_Bugs
    4.    
    5.     Dim oDLG As Dialog
    6.     Dim sFileName As String
    7.    
    8.     sFileName = Format(Now, "yyyy-mm-dd_hh-mm-ss") & " " & sType & ".doc"
    9.     Set oDLG = Application.Dialogs(wdDialogFileSaveAs)
    10.     With oDLG
    11.         .Application.ActiveDocument.SaveAs sFileName
    12.         .Update
    13.         .Show
    14.     End With
    15.     If Application.ActiveDocument.Saved = True Then
    16.         MySaveAs = True
    17.     Else
    18.         MySaveAs = False
    19.     End If
    20.     Exit Function
    21.    
    22. No_Bugs:
    23.     MySaveAs = False
    24. 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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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
  •  



Click Here to Expand Forum to Full Width