[AccessD] Inserting into an exported doc title

Gustav Brock Gustav at cactus.dk
Wed Dec 22 09:40:56 CST 2004


Hi Paul

You can create a GUID and use that as (part of) filename:

Option Compare Database
Option Explicit

Public Type GUID
  Data1         As Long
  Data2         As Integer
  Data3         As Integer
  Data4(0 To 7) As Byte
End Type

Private Declare Function CoCreateGuid Lib "ole32.dll" ( _
  ByRef pguid As GUID) As Long
  
Private Declare Function StringFromGUID2 Lib "ole32.dll" ( _
  ByRef rguid As Any, _
  ByVal lpstrClsId As Long, _
  ByVal cbMax As Long) As Long
'

Public Function GetGUIDString() As String

' Create a GUID and return its string representation.
'
' 2002-12-15. Cactus Data ApS, CPH.

  ' Length of GUID string per definition.
  Const clngGUID    As Long = 38
  ' Length of buffer with added space for zero terminator.
  Const clngBuffer  As Long = clngGUID + 1
  
  Dim udtGUID       As GUID
  Dim strGUID       As String * clngGUID
  Dim abytGUID()    As Byte
  
  ' Dim byte array.
  abytGUID() = String(clngBuffer, vbNullChar)
  ' Create GUID.
  If CoCreateGuid(udtGUID) = 0 Then
    ' GUID was successfully created.
    If StringFromGUID2(udtGUID, VarPtr(abytGUID(0)), clngBuffer) =
clngBuffer Then
      ' GUID was successfully copied into byte array abytGUID in
Unicode.
      ' Convert byte array to Ansi GUID string stripping zero
terminator.
      strGUID = abytGUID
    End If
  End If
  
  GetGUIDString = strGUID

End Function

>>> Paul.Rogers at summitmedia.co.uk 22-12-2004 16:18:39 >>>
I export the fields of an Access form to Word and save it in a stated
path. 

Can I add something unique to the name of the document so that Access
will
allow an unlimited number of this document to be saved, please Experts?


 appWord.ActiveDocument.SaveAs
"t:\WorksAllocation\FridayReports\FR.doc" 

The only unique field among the fields is the date.  Cheers paul




More information about the AccessD mailing list