![]() |
#1
|
|||
|
|||
![]()
Hey everyone,
I have an add-in I use for my wok that has a suite of document templates and vba code to automate the specific layout and formating of the documents. Its used for writing technical data and making sure that they all look the same. The add-in has been around for many years in our organisation and has been developed since Office 97 through to XP and in MS Word since Office 97. Im now using this add-in in Office 2016. On the whole it works fine, but im having a problem opening a document already created. I keep getting a custom error message. I found the code where the message is being generated, but Im not that good at troubleshooting this code. Can anyone take a look at this code and tell me if there is anything here that would stop it from working in MS Word 2016? Basically the error states that I havent selected a file, but the code does not give me a chance to select a file. Code:
Public Function SelectFileOpenDialog(strInitDir As String, strTitle As String, strFilter As String) As String Dim strTemp As String Dim strTemp1 As String Dim pathStr As String Dim i As Long Dim n As Long Dim j As Long Dim OFN As OPENFILENAME Dim lReturn As Long Dim strFilterString As String Dim strFilename As String OFN.lStructSize = Len(OFN) strFilterString = Replace(strFilter, "|", Chr(0)) & Chr(0) OFN.lpstrFilter = strFilterString OFN.nFilterIndex = 1 OFN.lpstrFile = String(257, 0) OFN.nMaxFile = Len(OFN.lpstrFile) - 1 OFN.lpstrFileTitle = OFN.lpstrFile OFN.nMaxFileTitle = OFN.nMaxFile OFN.lpstrInitialDir = strInitDir OFN.lpstrTitle = strTitle OFN.hwndOwner = GetActiveWindow() OFN.flags = 0 lReturn = GetOpenFileName(OFN) If lReturn = 0 Then MsgBox "You didn't select any file" strFilename = "" Else strFilename = Trim$(OFN.lpstrFile) ' copy the filename End If SelectFileOpenDialog = strFilename End Function Code:
Public Declare PtrSafe Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long Public gstrTypeSelected As String Public gstrJITypeSelected As String Private Type typToolbarNamePos strName As String lngPosition As Long End Type 'array to store the user's toolbar settings Public garPrevToobars() As typToolbarNamePos 'array to store the user's style settings Public garPrevStyles() As String Public Type typStyleName strStyleNameGeneric As String strStyleName97 As String strStyleName2003 As String bPromotable As Boolean bDemotable As Boolean End Type Public garStyleNames() As typStyleName Thanks in advance. |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Error message when opening any template | spiff1116 | Word | 6 | 11-04-2013 04:44 PM |
Template "File In Use" when opening 2 documents based on the same template | wendt | Word | 5 | 12-15-2009 12:37 AM |
Error opening word from a doc. | Davem501 | Word | 0 | 12-01-2009 02:10 AM |
Error when opening .vcf files | thorgal67 | Outlook | 0 | 04-06-2009 04:54 AM |
Outlook XP *.msg opening error msg | slmka | Outlook | 0 | 06-27-2007 09:00 PM |