• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

vba works on PC but not on another

Gandalf

Member
Hi, me again
I have a bit of code that opens a userform when the workbook opens. This works fine on the PC that it was written on but when I open it on my laptop (Panasonic Toughbook cf-19) it fails to open. Both machines are running the latest Office 365, Windows 11 pro and it is a trusted document on both. All other vba works just not the userform1. The code below is in Workbook

>>> use code - tags <<<
Code:
Private Sub Workbook_Open()
'Step 1: Select the specified sheet
    Sheets("Instructions").Select
    Range("A1").Select

' Show userform when workbook opens
    Call UserForm1.Show
        With UserForm1
            .Top = Application.Top + 320 '< change to what you want
            .Left = Application.Left + 850 '< change to what you want
        End With

End Sub

Any help would be appreciated, many thanks.
 
Last edited by a moderator:
Sorry, I forgot to attach the file
 

Attachments

  • Schedule monthly locking sessions with vba Development.xlsm
    113.4 KB · Views: 1

Gandalf

Please, open Your thread in correct Forum.
This thread has moved from Ask an Excel Question to VBA Macros.

What do happen when I open it on my laptop (Panasonic Toughbook cf-19) it fails to open. ?
Will You get any messages?
... I tested Your code and small size UserForm seems to open.
What should happen after You'll open that file?
 
Last edited:

Gandalf

Please, open Your thread in correct Forum.
This thread has moved from Ask an Excel Question to VBA Macros.

What do happen when I open it on my laptop (Panasonic Toughbook cf-19) it fails to open. ?
Will You get any messages?
... I tested Your code and small size UserForm seems to open.
What should happen after You'll open that file?
Apologies for the wrong forum and thank you for your response.
I get no error messages, the userform just does not appear. The userform has a command button on it which when clicked opens outlook and copies a range from the active worksheet as an image to the body of the email plus it also inserts the subject and sets the to addresses to those on the volunteers sheet. Then all the user needs to do is send the email.

Thanks for your help
 
... do You mean something like below?
Screenshot 2023-09-08 at 16.15.49.png
You could try to set its position more left and top
and
add some code to it ... eg beep after it opens.
 
What resolution is your display on the laptop, and is the Excel application maximised?
 
Many thanks to all. It is now fixed just by commenting out these lines of code
' With UserForm1 ' .Top = Application.Top + 320 '< change to what you want ' .Left = Application.Left + 850 '< change to what you want ' End With
 
If your goal is to center the userform, you might be better off with something like this:

Code:
    With UserForm1    'Center Screen on whatever monitor Excel is running on
        .StartUpPosition = 0
        .Left = Application.Left + (0.5 * Application.Width) - (0.5 * .Width)
        .Top = Application.Top + (0.5 * Application.Height) - (0.5 * .Height)
    End With
 
If your goal is to center the userform, you might be better off with something like this:

Code:
    With UserForm1    'Center Screen on whatever monitor Excel is running on
        .StartUpPosition = 0
        .Left = Application.Left + (0.5 * Application.Width) - (0.5 * .Width)
        .Top = Application.Top + (0.5 * Application.Height) - (0.5 * .Height)
    End With
Excellent, thank you. I am a novice at vba but thanks to this forum I am learning.
 
Back
Top