|
Question : Excel spreadsheet
|
|
I am having a few problems with a spreadsheet I'm revising. The top priorities are:
1. It must be protected so that it can not be copied or emailed. Proprietary amounts and stuff. Would changing the attributes to "Read-Only" do that?
2. It needs to be converted, via macro, to a Word document.
3. The only toolbar visible should be the one created via macros, which displays macro icons, delete and print. The "Save As" selection on the menu must be grayed out.
4. The action of the macros needs to be invisible.
5. Certain columns must be hidden and cannot be opened except by password. In fact, the whole sheet needs to be password protected.
6. "Bill To" "Ship To" pop-ups need to be created and linked to a Goldmine Contact Management database.
Please help if you can.
Thanks,
Zoegirl
|
|
Answer : Excel spreadsheet
|
|
HI,
To end this thread, here how it ends.
>>>>1. It must be protected so that it can not be copied or emailed. Proprietary amounts and stuff. Would changing the attributes to "Read-Only" do that?
Just by hiding column and the tools bar and making a print button for the form, it was all right
>>>>2. It needs to be converted, via macro, to a Word document.
No longer needed because the print form was satisfying.
3. The only toolbar visible should be the one created via macros, which displays macro icons, delete and print. The "Save As" selection on the menu must be grayed out.
We hide all of the toolsbar and create a brand new one for the purpose. here is the code: --------------------------------------------------------- Private Sub createToolbar() Dim cb As CommandBar Dim ctl As CommandBarButton
On Error Resume Next CommandBars("Proposal Macros").Delete CommandBars("Proposal Macros").Delete CommandBars("Proposal Macros").Delete CommandBars("Proposal Macros").Delete CommandBars("Proposal Macros").Delete On Error GoTo 0
Set cb = Application.CommandBars.Add(Name:="Proposal Macros", Position:=msoBarTop, Temporary:=False) cb.Visible = True
Worksheets("Sheet3").Shapes(1).Copy Set ctl = cb.Controls.Add(Type:=msoControlButton, Temporary:=False)
With ctl .Visible = True .OnAction = "open_n" .TooltipText = "Open Nautilus Mach" .FaceId = 0 .PasteFace End With
Worksheets("Sheet3").Shapes(2).Copy Set ctl = cb.Controls.Add(Type:=msoControlButton, Temporary:=False)
With ctl .OnAction = "open_s" .TooltipText = "Open Stairmaster" .FaceId = 0 .PasteFace End With
Worksheets("Sheet3").Shapes(3).Copy Set ctl = cb.Controls.Add(Type:=msoControlButton, Temporary:=False)
With ctl .OnAction = "open_w" .TooltipText = "Open Schwinn" .FaceId = 0 .PasteFace End With
Worksheets("Sheet3").Shapes(4).Copy Set ctl = cb.Controls.Add(Type:=msoControlButton, Temporary:=False)
With ctl .OnAction = "condensed" .TooltipText = "Condensed" .FaceId = 0 .PasteFace End With
Worksheets("Sheet3").Shapes(5).Copy Set ctl = cb.Controls.Add(Type:=msoControlButton, Temporary:=False)
With ctl .OnAction = "DisplayBillto" .TooltipText = "Ship To and Bill To Information" .FaceId = 0 .PasteFace End With
Worksheets("Sheet3").Shapes(6).Copy Set ctl = cb.Controls.Add(Type:=msoControlButton, Temporary:=False)
With ctl .OnAction = "printform" .TooltipText = "Print the invoice" .FaceId = 0 .PasteFace End With
End Sub
--------------------------------------------------------- 4. The action of the macros needs to be invisible.
This is kind of normal.............
5. Certain columns must be hidden and cannot be opened except by password. In fact, the whole sheet needs to be password protected.
We have done a password protected acces via the login and the password of GoldMine. We popup the userid and password and call GoldMine that the users used to validate it. Here is only the line of code to check that because all the code concerning GOLDMINE will be posted at question 6.
--------------------------------------------------------- gmHandle = GMW_LoadBDE("C:\Program Files\GoldMine2", "C:\Program Files\GoldMine2\gmbase", "C:\Program Files\GoldMine2\common", Login.Username.Text, Login.PassWord.Text)
---------------------------------------------------------
6. "Bill To" "Ship To" pop-ups need to be created and linked to a Goldmine Contact Management database.
We did a form within a listbox that allowed the user to select the contact information extract from GoldMine. Here is the code to extract from GoldMine (version 6).
Declaration first --------------------------------------------------------- Option Explicit Global cie(200) As String Global ad1(200) As String Global ad2(200) As String Global ad3(200) As String Global cty(200) As String Global sta(200) As String Global cot(200) As String Global zic(200) As String Global numerr As Integer Dim res As String Dim n1 As Integer Dim i1 As Integer Dim i As Integer Dim temps As String
Public Type GMLicInfo Licensee As String * 60 LicNo As String * 20 SiteName As String * 20 LicUsers As Long SQLUsers As Long GSSites As Long IsDemo As Long IsServerLic As Long IsRemoteLic As Long ISUSALic As Long iReserved1 As Long iReserved2 As Long iReserved3 As Long sReserved As String * 100 End Type
' LoadBDE Functions Public Declare Function GMW_LoadBDE Lib "GM6S32.DLL" (ByVal sSysDir As String, ByVal sGoldDir As String, ByVal sCommonDir As String, ByVal sUser As String, ByVal sPassword As String) As Long
Public Declare Function GMW_UnloadBDE Lib "GM6S32.DLL" () As Long
Public Declare Function GMW_SetSQLUserPass Lib "GM6S32.DLL" (ByVal sUserName As String, ByVal sPassword As String) As Long
' Business logic functions ' Name-Value parameter passing to business logic function GMW_Execute( Public Declare Function GMW_Execute Lib "GM5632.DLL" (ByVal szFunc As String, ByVal GMPtr As Any) As Long
Public Declare Function GMW_NV_Create Lib "GM6S32.DLL" () As Long
Public Declare Function GMW_NV_CreateCopy Lib "GM6S32.DLL" (ByVal hgmnv As Long) As Long
Public Declare Function GMW_NV_Delete Lib "GM6S32.DLL" (ByVal hgmnv As Long) As Long
Public Declare Function GMW_NV_Copy Lib "GM6S32.DLL" (ByVal hgmnvDestination As Long, ByVal hgmnvSource As Long) As Long
Public Declare Function GMW_GetLicenseInfo Lib "GM6S32.DLL" (ByRef LicInfo As Any) As Long
Public Declare Function GMW_NV_GetValue Lib "GM6S32.DLL" (ByVal hgmnv As Long, ByVal Name As String, ByVal DefaultValue As String) As Long
Public Declare Function GMW_NV_SetValue Lib "GM6S32.DLL" (ByVal hgmnv As Long, ByVal Name As String, ByVal Value As String) As Long
Public Declare Function GMW_NV_NameExists Lib "GM6S32.DLL" (ByVal hgmnv As Long, ByVal Name As String) As Long
Public Declare Function GMW_NV_EraseName Lib "GM6S32.DLL" (ByVal hgmnv As Long, ByVal Name As String) As Long
Public Declare Function GMW_NV_EraseAll Lib "GM6S32.DLL" (ByVal hgmnv As Long) As Long
Public Declare Function GMW_NV_Count Lib "GM6S32.DLL" (ByVal hgmnv As Long) As Long
Public Declare Function GMW_NV_GetNameFromIndex Lib "GM6S32.DLL" (ByVal hgmnv As Long, ByVal index As Long) As Long
Public Declare Function GMW_NV_GetValueFromIndex Lib "GM6S32.DLL" (ByVal hgmnv As Long, ByVal index As Long) As Long
' Low-Level DB funcs Public Declare Function GMW_DB_Open Lib "GM6S32.DLL" (ByVal sTableName As String) As Long
Public Declare Function GMW_DB_Close Lib "GM6S32.DLL" (ByVal lArea As Long) As Long
Public Declare Function GMW_DB_Append Lib "GM6S32.DLL" (ByVal lArea As Long, ByVal sRecID As String) As Long
Public Declare Function GMW_DB_Replace Lib "GM6S32.DLL" (ByVal lArea As Long, ByVal sField As String, ByVal sData As String, ByVal iAddTo As Long) As Long
Public Declare Function GMW_DB_Delete Lib "GM6S32.DLL" (ByVal lArea As Long) As Long
Public Declare Function GMW_DB_UnLock Lib "GM6S32.DLL" (ByVal lArea As Long) As Long
Public Declare Function GMW_DB_Read Lib "GM6S32.DLL" (ByVal lArea As Long, ByVal sField As String, ByVal sbuf As String, ByVal lbufsize As Long) As Long
Public Declare Function GMW_DB_Top Lib "GM6S32.DLL" (ByVal lArea As Long) As Long
Public Declare Function GMW_DB_Bottom Lib "GM6S32.DLL" (ByVal lArea As Long) As Long
Public Declare Function GMW_DB_SetOrder Lib "GM6S32.DLL" (ByVal lArea As Long, ByVal Stag As String) As Long
Public Declare Function GMW_DB_Seek Lib "GM6S32.DLL" (ByVal lArea As Long, ByVal sParam As String) As Long
Public Declare Function GMW_DB_Skip Lib "GM6S32.DLL" (ByVal lArea As Long, ByVal lSkip As Long) As Long
Public Declare Function GMW_DB_Goto Lib "GM6S32.DLL" (ByVal lArea As Long, ByVal sRecNo As String) As Long
Public Declare Function GMW_DB_Move Lib "GM6S32.DLL" (ByVal lArea As Long, ByVal sCommand As String, ByVal sParam As String) As Long Public Declare Function GMW_DB_Search Lib "GM6S32.DLL" (ByVal lArea As Long, ByVal sExpr As String, ByVal sRecID As String) As Long
Public Declare Function GMW_DB_Filter Lib "GM6S32.DLL" (ByVal lArea As Long, ByVal sFilterExpr As String) As Long
Public Declare Function GMW_DB_Range Lib "GM6S32.DLL" (ByVal lArea As Long, ByVal sMin As String, ByVal sMax As String, ByVal Stag As String) As Long
Public Declare Function GMW_DB_RecNo Lib "GM6S32.DLL" (ByVal lArea As Long, ByVal sRecID As String) As Long
Public Declare Function GMW_DB_IsSQL Lib "GM6S32.DLL" (ByVal lArea As Long) As Long
' Sync funcs Public Declare Function GMW_NewRecID Lib "GM6S32.DLL" (ByVal szRecid As String, ByVal szUser As String) As String
Public Declare Function GMW_UpdateSyncLog Lib "GM6S32.DLL" (ByVal sTable As String, ByVal sRecID As String, ByVal sField As String, byvalsAction As String) As Long
Public Declare Function GMW_ReadImpTLog Lib "GM6S32.DLL" (ByVal sFile As String, lDelWhenDone As Long, sStatus As String) As Long
Public Declare Function GMW_SyncStamp Lib "GM6S32.DLL" (sStamp As String, sOutBuf As String) As Long
' Datastream funcs Public Declare Function GMW_DS_Query Lib "GM6S32.DLL" (ByVal sSQL As String, ByVal sFilter As String, ByVal sFDlm As String, ByVal sRDlm As String) As Long
Public Declare Function GMW_DS_Range Lib "GM6S32.DLL" (ByVal sTable As String, ByVal Stag As String, ByVal sTopLimit As String, ByVal sBotLimit As String, ByVal sFields As String, ByVal sFilter As String, ByVal sFDlm As String, ByVal sRDlm As String) As Long
Public Declare Function GMW_DS_Fetch Lib "GM6S32.DLL" (ByVal iHandle As Long, ByVal sbuf As String, ByVal iBufSize As Long, ByVal iGetRecs As Long) As Long
Public Declare Function GMW_DS_Close Lib "GM6S32.DLL" (ByVal iHandle As Long) As Long
Public Declare Function GMW_IsUserGroupMember Lib "GM6S32.DLL" (ByVal szGroup As String, ByVal szUserID As String) As Long
' Misc WinAPI funcs used by VB with the GM5S32.DLL Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long) Public Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As String) As Long
---------------------------------------------------------
And the Code --------------------------------------------------------- Sub LoadGoldmine() Dim temps As String * 200 Dim gmHandle As Long
' Chnage the directory to meet the client needs On Error Resume Next gmHandle = GMW_LoadBDE("C:\Program Files\GoldMine2", "C:\Program Files\GoldMine2\gmbase", "C:\Program Files\GoldMine2\common", Login.Username.Text, Login.PassWord.Text) numerr = Err.Number On Error GoTo 0
If numerr > 0 Then res = MsgBox("Error linking GOLDMINE Database", vbOKOnly) numerr = 1 Exit Sub End If
If gmHandle = -4 Then res = MsgBox("Your user or password are invalid.", vbOKOnly) numerr = 1 Exit Sub End If
gmHandle = GMW_DB_Open("Contact1") n1 = GMW_DB_Range(gmHandle, "A", "Z", "COMPANY") n1 = GMW_DB_Top(gmHandle) i1 = 0
While n1 = 1 n1 = GMW_DB_Read(gmHandle, "Company", temps, 200) cie(i1) = temps n1 = GMW_DB_Read(gmHandle, "Address1", temps, 200) ad1(i1) = temps n1 = GMW_DB_Read(gmHandle, "Address2", temps, 200) ad2(i1) = temps n1 = GMW_DB_Read(gmHandle, "City", temps, 200) cty(i1) = temps n1 = GMW_DB_Read(gmHandle, "State", temps, 200) sta(i1) = temps n1 = GMW_DB_Read(gmHandle, "Country", temps, 200) cot(i1) = temps n1 = GMW_DB_Read(gmHandle, "Zip", temps, 200) zic(i1) = temps n1 = GMW_DB_Skip(gmHandle, 1) i1 = i1 + 1 Wend
n1 = GMW_DB_Close(gmHandle)
'nbcontact = i1 - 1
For i = 0 To i1 - 1 BillTo.Client.AddItem (cie(i)) Next i End Sub
Public Function PtrToStr(ByVal lpsz As Long) As String Dim strOut As String Dim lngStrLen As Long lngStrLen = lstrlen(ByVal lpsz) ' If returning larger packets, you may have to ' increase this value lngStrLen = 64000 If (lngStrLen > 0) Then strOut = String$(lngStrLen, vbNullChar) Call CopyMemory(ByVal strOut, ByVal lpsz, lngStrLen) lngStrLen = lstrlen(strOut) PtrToStr = Left(strOut, lngStrLen) Else PtrToStr = "" End If strOut = "" End Function
---------------------------------------------------------
That's about it.
Phetu
|
|
|
|