#1
|
|||
|
|||
Macro now requires file extension entered to open document
Hello, Let me start by stating that I do not know VBA, but I am considered the troubleshooter when something goes wrong. I work for a small manufacturer, and we create a document for each part that outlines what needs to be done. We have a relatively simple macro that we have been using for the last 11 or 12 years. It basically opens a document, then uses find and replace to change a couple of text fields, prints and closes it without saving. The document is opened by entering the file name only with no file extension. Up until this week it was working perfectly, but now the only way to get it to work is to enter the filename AND the extension. It seems a recent office update has changed something to cause this. This was discovered accidently by trying the macro on another computer and it worked without entering the file extension. We discovered that PC has office version 16.0.8431.2153, and the other PC has version 16.0.11328.20392. Having to enter an additional 4 keystrokes is cumbersome and time-consuming. I'm hoping that someone can advise me on how to get the macro to work as it has previously. I've attached the complete macro for review, and lastly, the documents we use are all in Word97 format (*.doc). Thank you for your help! |
#2
|
||||
|
||||
Try the following simplified version of your macro:
Code:
Sub Travellers() MsgBox ("IS FINEPRINT SET AS THE DEFAULT PRINTER?") fsDT = InputBox("Due Date is...", "Due Date", "DUE DATE") If File = "quit" Then Num = 1 Else Num = 0 Do While Num = 0 fsWON = InputBox("Enter Work Order Number or press Cancel to exit", "Work Order #", "Work Order Number") If fsWON = "" Then Exit Do File = InputBox("Name of the Part File to open?", "Open File", "Part Number") QTY = InputBox("Order Quantity is...", "Order Quantity", "Quantity") Documents.Open FileName:="S:\Word\Parts\" & File & ".doc", _ ConfirmConversions:=False, ReadOnly:=True, AddToRecentFiles:=False, _ Revert:=False, Format:=wdOpenFormatAuto, XMLTransform:="" With ActiveDocument With .Find .ClearFormatting .Replacement.ClearFormatting .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False .Text = "WRKORD" .Replacement.Text = fsWON .Execute Replace:=wdReplaceAll .Text = "QTY" .Replacement.Text = QTY .Execute Replace:=wdReplaceAll .Text = "DDT" .Replacement.Text = fsDT .Execute Replace:=wdReplaceAll End With .PrintOut Background = True .Close SaveChanges:=wdDoNotSaveChanges End With Loop End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
SUCCESS! Thank you Paul! I really appreciate your help! I also appreciate that you shortened it! Just an FYI - the original macro was first written back in 2007, so we have become pretty dependent on it. Have a great week!
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
OneNote requires interent access to open??? | rasmasyean | OneNote | 0 | 02-13-2017 01:59 PM |
Macro to Open to a Website When No Document Is Open | lostinwebspace | Word VBA | 1 | 02-13-2016 10:28 AM |
File extension issues | lkernen | Excel | 11 | 11-12-2013 01:17 PM |
excel cannot open the file .xlsx because the file format or file extension is not val | teddysika | Excel | 1 | 11-22-2012 06:06 AM |
Getting COMException Incompatible file type and file extension | sbalerao | Mail Merge | 0 | 04-21-2011 10:30 AM |