Public Function funOpenDoc()
Dim tmpArray As Variant
Dim LinksList As Variant
Dim appWD As Word.Application
Dim LastRow As Long, i As Long
Dim strAddy As String, strFilename As String, strTargFile As String
Dim strCode As String, strDocNo As String, strDocVer As String
' Find the last row with data in the spreadsheet
With Sheets("Sheet1")
LastRow = .Range("E" & .Rows.Count).End(xlUp).Row
End With
' Create a new instance of Word and make it visible
Set appWD = CreateObject("Word.Application")
appWD.Visible = True
For i = 1 To LastRow
strCode = Range("B" & i).Value 'Departmental code, 3 char
strDocNo = Range("C" & i).Value 'Departmental document ID, 3 char with leading zeros
strDocVer = Range("D" & i).Value 'Document version number, 3 char with leading zeros
strFilename = strCode & strDocNo & strDocVer
strAddy = Range("F" & i).Value 'the document hyperlink address
strTargFile = "C:\DocFolder\" & strFilename & ".doc"
' Tell Word to create a new document, then put in print view so headers & footers can show
appWD.Documents.Open (strAddy)
appWD.ActiveDocument.ActiveWindow.View.Type = wdPrintView
' Save the new document with a sequential file name.
appWD.ActiveDocument.SaveAs Filename:=strTargFile
' Close the new Word document.
appWD.ActiveDocument.Close
Next i
' Close the Word application.
appWD.Quit
End Function
ASKER
ToTheClipboard strTargFile ' Load the file name for the downloaded document to the clipboard.
' Create InternetExplorer Object
Set IE = CreateObject("InternetExplorer.Application")
'.... This opens a dialog box with a choice of: Open or Save As or Cancel
IE.Navigate strAddy
'... when the dialog box opens do these steps manually:
'1 click save as
'2 paste the file name that was loaded to clipboard
'3 press enter, the file will save
'4 Press F5 to get to the next document and repeat 1-4...only 244 documents to go :-(
' Clean up internet explorer
Set IE = Nothing
ASKER
Microsoft Excel topics include formulas, formatting, VBA macros and user-defined functions, and everything else related to the spreadsheet user interface, including error messages.
TRUSTED BY
ASKER
Updated. Word now has ribbon items when opened by the above, but the end result is the same.