+ Reply to Thread
Results 1 to 5 of 5

VBA: Read Signatures

Hybrid View

LeeHannah VBA: Read Signatures 02-04-2022, 06:12 AM
TMS Re: VBA: Read Signatures 02-04-2022, 10:50 AM
LeeHannah Re: VBA: Read Signatures 02-04-2022, 11:11 AM
CheeseSandwich Re: VBA: Read Signatures 02-04-2022, 11:17 AM
LeeHannah Re: VBA: Read Signatures 02-04-2022, 11:48 AM
  1. #1
    Registered User
    Join Date
    02-04-2022
    Location
    Germany
    MS-Off Ver
    365
    Posts
    4

    Question VBA: Read Signatures

    Hello Excel Forum, i have the following problem:

    My macro reads the signatur of word documents.
    The example DOCX File has 9 signaturefields, 5 are signed and 4 are unsigned.

    I get signatures only when i use subset = 0 (msoSignatureSubsetSignaturesAllSigs). //It counts only the signed Signaturefields

    Maybe someone knows my mistake:

      Dim oobjWDApp As Object 'Word.Application
      Dim oobjDoc As Object  'Word.Document
      Dim owdRange As Object ' Word.Range
    
    Set oobjWDApp = CreateObject("Word.Application")
    oobjWDApp.Visible = False
    Set oobjDoc = oobjWDApp.Documents.Open(strQuellDat, ReadOnly:=True)
    
    oobjDoc.Signatures.Subset = 0
    Debug.Print "0 -> " & oobjDoc.Signatures.Count
    oobjDoc.Signatures.Subset = 1
    Debug.Print "1 -> " & oobjDoc.Signatures.Count
    oobjDoc.Signatures.Subset = 2
    Debug.Print "2 -> " & oobjDoc.Signatures.Count
    oobjDoc.Signatures.Subset = 3
    Debug.Print "3 -> " & oobjDoc.Signatures.Count
    oobjDoc.Signatures.Subset = 4
    Debug.Print "4 -> " & oobjDoc.Signatures.Count
    oobjDoc.Signatures.Subset = 5
    Debug.Print "5 -> " & oobjDoc.Signatures.Count
    oobjDoc.Signatures.Subset = 6
    Debug.Print "6 -> " & oobjDoc.Signatures.Count
    Output looks like this:

    0 -> 5
    1 -> 0
    2 -> 0
    3 -> 0
    4 -> 0
    5 -> 0
    6 -> 5
    2 should be 9 , 3 should be 5 and 4 should be 4.
    I dont know whats wrong

    Thanks in advance
    Last edited by LeeHannah; 02-04-2022 at 06:15 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,454

    Re: VBA: Read Signatures

    Cross-posted at https://stackoverflow.com/questions/...signaturelines
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    02-04-2022
    Location
    Germany
    MS-Off Ver
    365
    Posts
    4

    Re: VBA: Read Signatures

    Found the solution.

    Added sleep 5000 after XXX.Documents.Open so the document was full openend.

    Maybe there is a better solution, like asking word if it is finished or something like readystate

  4. #4
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2501
    Posts
    1,448

    Re: VBA: Read Signatures

    Sub test()
        Dim oobjWDApp As Object, oobjDoc As Object
        Dim totSig As Long, ySig As Long, nSig As Long
        
        Set oobjWDApp = CreateObject("Word.Application")
        oobjWDApp.Visible = True
        Set oobjDoc = oobjWDApp.Documents.Open("C:\Users\jbloggs\Desktop\test.docx", ReadOnly:=True)
        DoEvents
        
        oobjDoc.Signatures.Subset = 2: totSig = oobjDoc.Signatures.Count ' total sig lines
        oobjDoc.Signatures.Subset = 3: ySig = oobjDoc.Signatures.Count ' signed
        oobjDoc.Signatures.Subset = 4: nSig = oobjDoc.Signatures.Count ' unsigned
        
        Debug.Print "Total signature lines: " & totSig
        Debug.Print "Signed lines: " & ySig
        Debug.Print "Unsigned lines: " & nSig
    End Sub

  5. #5
    Registered User
    Join Date
    02-04-2022
    Location
    Germany
    MS-Off Ver
    365
    Posts
    4

    Re: VBA: Read Signatures

    Thank you for the reply ChesseSandwich,

    DoEvents didn't work for me

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Signatures???
    By JimmyWilliams in forum The Water Cooler
    Replies: 1
    Last Post: 08-15-2017, 07:11 PM
  2. Signatures
    By JimmyWilliams in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 06-29-2017, 10:46 PM
  3. Avatars and Signatures
    By Solus Rankin in forum The Water Cooler
    Replies: 5
    Last Post: 07-08-2013, 12:29 PM
  4. User Signatures
    By Craig K. in forum The Water Cooler
    Replies: 2
    Last Post: 06-17-2013, 03:39 PM
  5. Cluttering signatures
    By Pepe Le Mokko in forum The Water Cooler
    Replies: 3
    Last Post: 01-24-2012, 06:47 AM
  6. [SOLVED] 97 digital signatures
    By Harley in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-07-2005, 01:05 PM
  7. [SOLVED] Signatures
    By Jasmine in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-16-2005, 03:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1