+ Reply to Thread
Results 1 to 24 of 24

Run macro on a specific PC

  1. #1
    Registered User
    Join Date
    11-11-2010
    Location
    here
    MS-Off Ver
    Excel 2010
    Posts
    47

    Run macro on a specific PC

    hello friends,

    I want to ask you if it's possible to run a macro on a specific pc, I mean to use a workbook.
    a sort of protection.
    any help is really appreciated

    chris
    Last edited by chris85; 12-20-2010 at 05:10 AM.

  2. #2
    Forum Contributor
    Join Date
    05-09-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    315

    Re: Run macro on a specific PC

    Try this:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-11-2010
    Location
    here
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Run macro on a specific PC

    hi mojo,
    thanks for your solution! i'll try it tmw n i tell you!

    chris

  4. #4
    Registered User
    Join Date
    11-11-2010
    Location
    here
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Run macro on a specific PC

    hi
    I rcv an error variable not define!
    have anybody any ideea how could it be solved?
    thx in advance
    chris
    Last edited by chris85; 12-19-2010 at 11:09 AM.

  5. #5
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,760

    Re: Run macro on a specific PC

    Perhaps this will work better?

    Please Login or Register  to view this content.
    To find your computer name as your systen sees it you could add the line
    Please Login or Register  to view this content.
    before the line
    Please Login or Register  to view this content.
    When I checked my computer name in "Control Panel" -> System it was a mix of lower case letters and numbers but the value shown in the
    MsgBox was upper case letters and numbers. So I had to change computer name in my macro to upper case letters to get it to work.

    HTH

    Alf
    Last edited by Alf; 12-19-2010 at 12:19 PM.

  6. #6
    Registered User
    Join Date
    11-11-2010
    Location
    here
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Run macro on a specific PC

    Alf, thx!
    i'll try right now!
    christian

  7. #7
    Registered User
    Join Date
    11-11-2010
    Location
    here
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Run macro on a specific PC

    Alf, i added the code and i'm expecting not to work on other pc except mine, i mean that defined!

  8. #8
    Registered User
    Join Date
    11-11-2010
    Location
    here
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Run macro on a specific PC

    here is my code, did i do something wrong?
    Please Login or Register  to view this content.

  9. #9
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Run macro on a specific PC

    Yes, you did something wrong.

    Your first macro isn't doing anything.

    Your second macro needs to be within your first macro as the "Else" part of your "If".

  10. #10
    Registered User
    Join Date
    11-11-2010
    Location
    here
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Run macro on a specific PC

    hi Cutter,
    thank you for response! kindly ask you to correct my code if you want!
    chris

  11. #11
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Run macro on a specific PC

    Is your second macro doing what you want it to do as it is currently written?

  12. #12
    Registered User
    Join Date
    11-11-2010
    Location
    here
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Run macro on a specific PC

    Yes, it does.
    i just want not to run it on other pc, that's all!
    thank you very much
    christian

  13. #13
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Run macro on a specific PC

    That being the case, try this:

    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    11-11-2010
    Location
    here
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Run macro on a specific PC

    thx, i'll try n i tell you!
    chris

  15. #15
    Registered User
    Join Date
    11-11-2010
    Location
    here
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Run macro on a specific PC

    hi,
    sorry, it's not working.
    chris

  16. #16
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Run macro on a specific PC

    How is it "not working"?

    Is it running as expected on your computer AND on another?
    Is it not running as expected on your computer OR on another?
    Are you getting an error when you run it?
    Does anything happen when you run it?

    You need to provide more information.

    Run this macro on YOUR computer as a test:

    Please Login or Register  to view this content.
    If you don't get a message box after running this macro then you are using the wrong name for your computer which means you didn't read and follow post #5 properly.

  17. #17
    Registered User
    Join Date
    11-11-2010
    Location
    here
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Run macro on a specific PC

    hi Cutter, good morning!
    thank you for your help. i have no ideea why the code did not working properly, actually it was working on any pc.
    i read post 5 for several times, i deleted all n then i added the code again. it works very well.
    please do not get at me, i'm just a beginner!
    i appreciate your patience and help.

    chris

  18. #18
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Run macro on a specific PC

    Good morning Chris

    I wasn't "getting at you". I was just asking for a clearer explanation and suggesting what you can try so that we can provide you with the appropriate assistance.

    Glad to hear you got it to work.

  19. #19
    Registered User
    Join Date
    11-11-2010
    Location
    here
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Run macro on a specific PC

    hi Cutter,
    thx!

    chris

  20. #20
    Registered User
    Join Date
    12-18-2010
    Location
    UK
    MS-Off Ver
    2003, 2007, 2010
    Posts
    79

    Re: Run macro on a specific PC

    Chris

    When you say it is not working, do mean that the macro is throwing an error message or that your own macro is working under all circumstances, ie on any PC?
    David
    Access and Excel Developer | UK

  21. #21
    Registered User
    Join Date
    11-11-2010
    Location
    here
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Run macro on a specific PC

    David,
    it was working on any pc without error msg(s), then the issue was solved.
    i'm learning...
    Chris

  22. #22
    Registered User
    Join Date
    12-18-2010
    Location
    UK
    MS-Off Ver
    2003, 2007, 2010
    Posts
    79

    Re: Run macro on a specific PC

    Chris

    Me too. Missed page two of these posts altogether. Beginner.

    One thing I am not up to judging yet on this Forum is that when people are exchanging code how far should I go as a potential contributor. For instance, in the code featured in this thread, nobody is talking error handling or code structuring. Should I be concerned at this?

  23. #23
    Registered User
    Join Date
    11-11-2010
    Location
    here
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Run macro on a specific PC

    Nobody is talking about error because there was no error, not being an expert I'm not worried about code structuring. as i said, it's ok now!

  24. #24
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,760

    Re: Run macro on a specific PC

    Hi David

    that when people are exchanging code how far should I go as a potential contributor
    You of course do the best as you can with the available information. If you have read a number of posts in this forum you find that quite often the OP comes back with additional questions because they did not give enough or sometimes wrong information the first time because the OP’s having spent so much time trying to solve the problem that they forget to mention the obvious, i.e. obvious to them but not to one trying to help.

    For instance, in the code featured in this thread, nobody is talking error handling or code structuring. Should I be concerned at this?
    If I may refer to the specific code I wrote I did test it before I presented it as a solution to a specific problem. In the testing I found a discrepancy between the computer name found in “System Properties” compared to what the macro showed in “MsgBox”. I did comment on this and proposed how to check what name to use. Normally I test to check that the code works and if so I usually post it with a friendly HTH.

    Code structuring? I do start macros with “Option Explicit” and “Dim” the variables because I find it easier to analyze my code but I seldom comment the different statement, the how and the why. I guess it’s a matter of personal preference and how much time I can spend. If the OP wants more information they may ask and I’ll do my best to answer. And if I give a wrong answer hopefully somebody else in the forum will correct me and give the right answer.

    Looking at posts it seems to me that they who make a living out of working with Excel tends to give better solutions, better i.e. that is they do add a number of comment in the macros and they also do tend to ask question of the OP so their solutions are more fool proof. But they are used to work with customers who not always know what they need. Me I’m still learning so that reflects on the quality of my answers.

    Alf

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1