Screen updating translate
However, one of the reasons for using the original code was because I could understand the code and therefore its actions. If I need to add multiple variables to the string (if my userform contains Opt3, 4, 5 etc) do I just continue to duplicate the 'Else If'' statement ? Open("E:\MYDOCUMENT" & Str Var & ".dot", _ Add To Recent Files:=False, Visible:=False) And what is meant to happen if two of them are true (assuming that's possible)?
Paste Thanks macropod, I will try this code to see if it helps. You could also use a series of If statements on their own: Dim Doc As Document, Str Var As String If Opt1 = True Then Str Var = "" If Opt2 = True Then Str Var = "2" If Opt3 = True Then Str Var = "3" If Opt4 = True Then Str Var = "4" Set Doc = Documents.
Some of the performance issue is network speed related, which is outside of your control from VBA. Not using selection object, but a range object instead. but you no longer have a selection object in that document (since selection only refers to the Active Document). In that case, I would suggest looking up "Working with Ranges" in the Word help file.
Visible = False, which Paul has already demonstrated). You don't have to select to copy, you can simply use o Doc. Open method will speed up the process of opening and closing... But, big picture, worrying about screen-flickering sounds like you're trying to make this super slick-- which is, frankly, probably not possible without a lot of help, given your level of expertise, unless you're also using this as a learning exercise.
Microsoft Translator is a free, personal translation app for 60 languages, to translate text, voice, conversations, camera photos and screenshots.
You can even download languages for offline translation for free to use when you travel!
Paste Hi Neil, Yes, you could use more Else If arguments, though it does seem odd to have so many Opt variables first.
Dim str VARIABLE1 As String If Opt1 = True Then str VARIABLE1 = Word. especially if the OP gets to the point where so many documents are being opened/closed in the background that the screen is actually frozen for a noticeably long time. Sorry to be a pain macropod but would you mind showing how the 'Insert File' method works and a code for it based on the above? - Neil I think Paul was asking whether there are scenarios where you need to open/copy/close/paste from multiple documents, not whether you might have multiple option buttons selected at once (in which case, I would suggest a use of the collection object, but it doesn't appear to be a need for you) The performance hits are the (primarily) the following: 1. Insert File might be helpful, although I don't think it will be appreciably different from opening with . Copy Making the Visible parameter false in the Documents. One of those commands tells Word to give some visual feedback to the end-user (i.e., highlight stuff in black) and one just does it (that's the concept of *the* Selection vs. You'll want to keep looking for any use of a selection object in your code, and then post sample for how to translate (I'm guessing it's rampant, since at least some of this started as a recorded macro-- which is a great way to start, very easy to remember what you did and see the recorded equivalent). Open("E:\MYDOCUMENT" & Str Var & ".dot", _ Add To Recent Files:=False, Visible:=False) Doc. Option 1 - Statement 1 Option 2 - Statement 2 Option 3 - Statement 3" When using Option Buttons in a Frame you can only select one Option Button at a time I have found.This tends to be when the template being copied opens/closes. In some respects, the flickering can be nice-- it lets you know something is going on.Is there anything that I can add to my code that might eliminate the updating? Would it help it the above was placed in the template that is being opened ? Screen Updating controls the updating of the current document's window, but not the updating that occurs when documents are opened/closed. If your screen "locks up" because of an effective use of the Application.
Dependant upon their selection, will depend upon what document is opened, copied, and then pasted into the template. Try something along the lines of: Dim Doc As Document, Str Var As String Str Var = "" If Opt1 = True Then Str Var = "" Else If Opt2 = True Then Str Var = "2" End If Set Doc = Documents. Open("E:\MYDOCUMENT" & Str Var & ".dot", _ Add To Recent Files:=False, Visible:=False) Doc. For example the userform might say: "Please select one of the following statements to include in your report.