LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default How to return the machine name?

Maury Markowitz formulated on Saturday :
On Apr 27, 3:33Â*pm, GS wrote:
Â* If Not Environ("ComputerName") = <ServerName Then _
Â* Â* ThisWorkbook.Close SaveChanges:=False


Looking over the thread€¦

The machine in question is a PC, a virtual "cloud server" to be exact.
My current model is to place a template file on the server, and ask
the user the open it there. As part of the scripts, it will created
and save out a new file (a simple one, no scripts) that can then be
opened on any Mac or PC.

So I think the Environ method should work for this purpose.

But the purpose of this call is to make sure they open it on the right
machine. If they don't, they get a warning. But I *suspect* that if
they were to open it on the Mac, the compiler would trip on the
Enviorn call and put up some nasty user-unfriendly message. Any ideas
on how to avoid this?


You can use an error handler...

Sub Whatever()
'..Dim stuff

On Error GoTo errhandler 'Macs will choke on this
If Not Environ("ComputerName") = <computername Then _
ThisWorkbook.Close SaveChanges:=False

'..Do stuff


normalexit:
Exit Sub

errhandler:
MsgBox "You can't use this template on this machine!"
End Sub

...assumes the stored project runs on the machine accessing the project
on the server.

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Remote Machine not available Alan[_8_] Excel Programming 1 September 22nd 09 09:22 AM
Strange formatting on one machine only Gumbatman Excel Programming 0 November 7th 08 04:40 PM
Reference & update destin. cells on 1st machine from source workbook on 2nd machine. [email protected] Excel Discussion (Misc queries) 6 February 28th 06 05:15 AM
Password not working on one machine M. Lord Excel Discussion (Misc queries) 4 July 21st 05 05:34 PM
Macro doesn't run on new machine Jamie Excel Programming 3 June 8th 05 11:42 PM


All times are GMT +1. The time now is 02:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"