Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Two macros I have, one to size down a Word window down to 20% of the RH side of the screen, and the other to 80% on the LH side, have stopped working. (They are for reference files while I work on the other screen).

These are my macros:

Sub RestoreDown()
    Dim myWindow1 As Window, myWindow2 As Window
    Set myWindow1 = ActiveWindow
    With myWindow1
        .WindowState = xlNormal
        .Top = 0
        .Left = (Application.UsableWidth * 0.92) + 1
        .Height = Application.UsableHeight
        .Width = Application.UsableWidth * 0.2
    End With
End Sub
Sub RestoreDown2()
    Dim myWindow1 As Window, myWindow2 As Window
    Set myWindow1 = ActiveWindow
    With myWindow1
        .WindowState = xlNormal
        .Top = 0
        .Left = (Application.UsableWidth * 0.12) + 1
        .Height = Application.UsableHeight
        .Width = Application.UsableWidth * 0.8
    End With
End Sub

They have stopped working. I get the error message 'Object variable or With block variable not set'. I'm not aware of having changed anything.

I should point out that I'm not a technical geek. I use macros a lot for my work (copy-editing of texts) but I'm only at the 'I wish' stage of knowing a lot about VBA. Please kindly bear this in mind when responding!

share|improve this question
    
What caused them to stop working? If you don't know the actual reason then what was the trigger event? Who wrote these macros? –  Ramhound Mar 7 '13 at 12:58
    
Both of those run on my system without error. Does this happen in all documents you run them on? Does it only happen after you've run it on another document first? What happens if you close all Word docs and reopen them before running the macro? How about after reboot? –  CharlieRB Mar 7 '13 at 13:00
    
Ramhound: I'm afraid I don't know what might have triggered this. My Normal.dotm did get corrupted recently, or at least that's what I assume: all my macros seemed to have disappeared. Fortunately I keep a Word file with them all in, so I simply pasted them all back into VBA and they seem to work, except these ones. –  sarah woodton Mar 7 '13 at 13:13
    
CharlieRB: My PC closes down every night and I reboot in the morning, so yes, I've rebooted and they still don't work. –  sarah woodton Mar 7 '13 at 13:14
    
@sarahwoodton - What caused the corruption. What versions of Windows are you using? –  Ramhound Mar 7 '13 at 13:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.