![]() |
KnowBrainer Speech Recognition | ![]() |


|
Topic Title: How to display "Computer Name" in footer? Topic Summary: Created On: 06/11/2012 09:57 AM Status: Post and Reply |
|
![]() |
- Roger | - 06/11/2012 09:57 AM |
![]() |
- Bruce Tjosvold | - 06/12/2012 04:02 PM |
![]() |
- Bruce Tjosvold | - 06/12/2012 04:13 PM |
![]() |
- Roger | - 06/16/2012 06:58 AM |
![]() |
- Larry Allen | - 06/21/2012 10:26 AM |
![]() |
- R. Wilke | - 06/17/2012 05:17 AM |
![]() |
- Roger | - 06/17/2012 05:53 AM |
![]() |
- R. Wilke | - 06/17/2012 06:30 AM |
![]() |
- monkey8 | - 06/24/2012 12:36 PM |
![]() |
- Roger | - 06/25/2012 01:11 PM |
![]() |
- monkey8 | - 06/25/2012 06:19 PM |
![]() |
- Larry Allen | - 06/29/2012 11:55 PM |
![]() |
- Roger | - 06/30/2012 05:21 AM |
|
|
|||
|
I'm using Word 2003 and Windows XP but I'm unable to show the computer name in the footer. I can show the author and path. Someone said there is a way to do this in VBA. '******************** Code Start **************************
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Private Declare Function apiGetComputerName Lib "kernel32" Alias _
"GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function fOSMachineName() As String
'Returns the computername
Dim lngLen As Long, lngX As Long
Dim strCompName As String
lngLen = 16
strCompName = String$(lngLen, 0)
lngX = apiGetComputerName(strCompName, lngLen)
If lngX <> 0 Then
fOSMachineName = Left$(strCompName, lngLen)
Else
fOSMachineName = ""
End If
End Function
'******************** Code End **************************
The simplest way, although not 100% dependable, is Environ("computername")
More complicated, but also more dependable:
Private Declare Function GetComputerName Lib "kernel32" _ Function ComputerName() As String
You can then use the ComputerName function.
Does anyone know how to do this? Does anyone know the best way to do this? ------------------------- Intel Pent D 930 Dual Core Proc 3.0 GHz, 4MB L2 Cache on a Intel Desktop Board D945PVS 800MHz FSB, 4GB 667MHz DDR2 Non-ECC CL5 DIMM (Kit of 2), 150 GB, 10K RPM, 16 MB Cache - WD Raptor SATA HD, Win XP Pro Ver 2002 SP3 32-bit, Andrea USB Soundpod, Sennheiser ME 3, DNS Pro 11.5 using BestMatch III. |
|||
|
|
|||
|
|
|||
|
Roger,
Here is some code to pop up a window with the value of each system variable. It may get you closer tpo your goal.
Bruce
' ------------------------- 1
|
|||
|
|
|||
|
|
|||
|
or, a much simpler script
'#Reference {F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}#1.0#0#C:\WINNT\System32\wshom.ocx#Windows Script Host Object Model (Ver 1.0) ------------------------- 1
|
|||
|
|
|||
|
|
|||
|
Bruce, Thank you for your efforts so far! However when I ran your "a much simpler script" I got a Compile Error. I attached screen shots of what I am doing in the attached file called "Compile Error.doc" Please let me know if I am doing anything wrong? I am new to using VBA in dot files.
Thanks again, Roger
------------------------- Intel Pent D 930 Dual Core Proc 3.0 GHz, 4MB L2 Cache on a Intel Desktop Board D945PVS 800MHz FSB, 4GB 667MHz DDR2 Non-ECC CL5 DIMM (Kit of 2), 150 GB, 10K RPM, 16 MB Cache - WD Raptor SATA HD, Win XP Pro Ver 2002 SP3 32-bit, Andrea USB Soundpod, Sennheiser ME 3, DNS Pro 11.5 using BestMatch III. |
|||
|
|
|||
|
|
|||
|
To make this work, you need to add a "Reference" to the Windows Scripting Host Object Model. In the Microsoft VB Editor window, go to Tools, then References. Scroll down the "Available References" to Windows Script Host Object Model and check the box. Click OK. It is possible but not likely that your system will not have the Windows Script Host Object Model if that software is not installed.
------------------------- Larry Allen |
|||
|
|
|||
|
|
|||
|
Roger, ------------------------- Well, it's past the point where we can make any changes in the code, but we can still make changes to the Easter Egg! |
|||
|
|
|||
|
|
|||
|
RĂ¼diger
That would be hard to do since all I want is the computer name to be in the footer of my Word document. Roger ------------------------- Intel Pent D 930 Dual Core Proc 3.0 GHz, 4MB L2 Cache on a Intel Desktop Board D945PVS 800MHz FSB, 4GB 667MHz DDR2 Non-ECC CL5 DIMM (Kit of 2), 150 GB, 10K RPM, 16 MB Cache - WD Raptor SATA HD, Win XP Pro Ver 2002 SP3 32-bit, Andrea USB Soundpod, Sennheiser ME 3, DNS Pro 11.5 using BestMatch III. |
|||
|
|
|||
|
|
|||
|
It is just that the code provided by Bruce isn't meant to be copied and pasted into the VBA editor the way you did it, going by your screenshot. It cannot work this way, being Advanced Scritpting code. I would like to show you how this can be dones, but then I have Word 2010, German edition, and things are likely a little different here from what you have. So you might either go on following the samples you have come up with, but please note than almost any sample needs to be adopted according to the given environment, and just won't work from the start, or you might start from scratch by learning it, which may be a long way to go - but worth it in the end.
However, if the only reason for coming up with VBA was being a last resort in order to compensate for missing functionality in Word by itself, and if, in other words, you aren't using VBA for other reasons also, and haven't really started with it, you may as well go on with Advanced Scripting in Dragon, since you have the Professional version, and anything that can be done in VBA may also be done in Advanced Scripting, aside from both of us talking the same language then (DNS Pro 11.5), and a few more around I would expect to be happy to help also. RĂ¼diger ------------------------- Well, it's past the point where we can make any changes in the code, but we can still make changes to the Easter Egg! |
|||
|
|
|||
|
|
|||
|
That's a lot of code to get a computer name, there is a built-in command with VBA and Advanced Scripting that will give you the computer name as a string: SendKeys Environ$("commonprogramfiles") -------------------------
|
|||
|
|
|||
|
|
|||
|
Allen and Lindsay,
I added/clicked checkbox for Windows Script Host Object Model. I then added Environ$("computername") to the footer. But it did not work.
Please note: in this instance I do not want to use speech recognition to display the computer name
------------------------- Intel Pent D 930 Dual Core Proc 3.0 GHz, 4MB L2 Cache on a Intel Desktop Board D945PVS 800MHz FSB, 4GB 667MHz DDR2 Non-ECC CL5 DIMM (Kit of 2), 150 GB, 10K RPM, 16 MB Cache - WD Raptor SATA HD, Win XP Pro Ver 2002 SP3 32-bit, Andrea USB Soundpod, Sennheiser ME 3, DNS Pro 11.5 using BestMatch III. |
|||
|
|
|||
|
|
|||
|
Well I am no expert on Microsoft Word but I doubt you can insert environmental variable directly into the footer. You can enter your VBA code directly into an event, e.g. the page set up event, probably easier still is just to run a VBA macro just before you save or print the document. So just add a Word macro, called "footer", with something like the following: -------------------------
|
|||
|
|
|||
|
|
|||
|
Now I better understand what you want to do. Add a field at the proper place in the document, using the Word Field choosing DocProperty and then Computer as the Field Property. I've attached your document modified in this way.
------------------------- Larry Allen |
|||
|
|
|||
|
|
|||
|
Larry Allen, ------------------------- Intel Pent D 930 Dual Core Proc 3.0 GHz, 4MB L2 Cache on a Intel Desktop Board D945PVS 800MHz FSB, 4GB 667MHz DDR2 Non-ECC CL5 DIMM (Kit of 2), 150 GB, 10K RPM, 16 MB Cache - WD Raptor SATA HD, Win XP Pro Ver 2002 SP3 32-bit, Andrea USB Soundpod, Sennheiser ME 3, DNS Pro 11.5 using BestMatch III. |
|||
|
|
|||
FuseTalk Standard Edition v4.0 - © 1999-2013 FuseTalk™ Inc. All rights reserved.