Function ExtractReviewCode(sFile As String)
'This isn't being actively used, only set up to see
'if it could be done...
'1. To save time Extract specific page: EOR Review (page 2)
'2. Open with Word to locate the Engineer Review Code(s) within the table.
' Visually, appears to be row 5 col 2, but there must be a hidden col as
' location is row 5 col 3
'3. Gather cell data from the other 2 Engineer Review Codes on the page
' in case they differ and a decision needs to be made as to which Code to use.
'Learned can convert pdf to word simply by opening the pdf in word from:
'https://social.msdn.microsoft.com/Forums/office/en-US/2d3a5cd3-38c3-4811-b3df-4f60848aec54/can-i-use-vba-to-convert-pdf-files-to-word-docs-or-text-files?forum=worddev
'Open word and the file, since no need to save
'or convert the file after it is opened, close the file without saving. Only
'issue is that not sure how to by-pass the prompt to convert to Word. Seems this
'popup doesn't always come to the front, so if not aware of it, may give the
'impression that the program is stuck/hanging/freezing when in fact is waiting
'for user to click on OK
'20190422
'The code in this link indicates a method to suppress the popup message
'https://social.msdn.microsoft.com/Forums/en-US/57f49b29-58cf-45e5-97cc-985fdd9a8c17/open-pdf-in-word-without-conversion-message?forum=isvvba
'On that page, search for: Graham MayorMVP Sunday, March 13, 2016 9:55 AM (above that is the code)
'20190422
Dim WordApp As Object
Dim worddoc As Object
Dim sFileName As String
Dim bAppAlreadyOpen As Boolean
Dim stReviewCode1 As String
Dim stReviewCode2 As String
Dim stReviewCode3 As String
Dim stComments As String
bAppAlreadyOpen = True
'Get an instance of word to work with
'See if Word is already running
On Error Resume Next
Set WordApp = GetObject(, "Word.Application")
If Err.Number <> 0 Then
'Launch a new instance of Word
Err.Clear
On Error GoTo Error_Handler
Set WordApp = CreateObject("Word.Application")
bAppAlreadyOpen = False
End If
'Determine the Word doc filename without the path or extension
sFileName = FileNameNoExt(sFile)
'Open the document
Set worddoc = WordApp.Documents.Open(sFile)
worddoc.ActiveWindow.View.ReadingLayout = False
WordApp.Application.Visible = True
If worddoc.Tables.Count = 1 Then
With worddoc.Tables(1)
stReviewCode1 = .cell(5, 3).Range.Text
stReviewCode2 = .cell(14, 3).Range.Text
stReviewCode3 = .cell(23, 3).Range.Text
End With
SubmittalReviewCode = RegExData(stReviewCode1, "[a-zA-Z]+") & ", " & RegExData(stReviewCode2, "[a-zA-Z]+") & ", " & RegExData(stReviewCode3, "[a-zA-Z]+")
End If
Error_Handler_Exit:
worddoc.Close False
Set worddoc = Nothing
If bAppAlreadyOpen = False Then WordApp.Quit
Set WordApp = Nothing
Exit Function
Error_Handler:
MsgBox "The following error has occured" & vbCrLf & vbCrLf & _
"Error Number: " & Err.Number & vbCrLf & _
"Error Source: PrintWordDoc" & vbCrLf & _
"Error Description: " & Err.Description _
, vbOKOnly + vbCritical, "An Error has Occured!"
Resume Error_Handler_Exit
End Function