Solved

creating a GUID in excel

Posted on 2012-03-22
3
3,835 Views
Last Modified: 2012-04-01
Hello All-
I want to generate in a cell a GUID for the excel file. However, it cannot change every time you open/ close it. It would be a once and done deal. So re opening it to make some edits, keeps the GUID the same.

It has to do with SSIS package I built, and in order for the DB to update the already imported fields, I need something unique that won't change each time you open the file up on the client side.

Any Ideas...Thanx
0
Comment
Question by:BKennedy2008
  • 2
3 Comments
 
LVL 7

Expert Comment

by:tipsybroom
Comment Utility
try this:

Public Sub TestGetGUID() 
    MsgBox GetGUID, vbInformation, "GUID Generated" 
End Sub 
 
Public Function GetGUID() As String 
    GetGUID = Mid$(CreateObject("Scriptlet.TypeLib").GUID, 2, 36) 
End Function 

Open in new window


or this:

Public Type TYP_GUID
            bytes(15) As Byte
End Type
 
Public Declare Function CoCreateGuid Lib "OLE32.dll" _
                       (Guid As TYP_GUID) As Long
Public Declare Function StringFromGUID2 Lib "OLE32.dll" _
                       (Guid As TYP_GUID, _
                        ByVal lpszString As String, _
                        ByVal iMax As Long) As Long
 
Public Function CreateGUID() As String

    Dim uGuid   As TYP_GUID
    Dim sBuffer As String
    Dim lResult As Long
 
    sBuffer = VBA.Space(78)
    CoCreateGuid uGuid
    lResult = StringFromGUID2(uGuid, sBuffer, Len(sBuffer))
    CreateGUID = _
    Left$(StrConv(sBuffer, vbFromUnicode), lResult - 1)
 
End Function

Open in new window

0
 

Accepted Solution

by:
BKennedy2008 earned 0 total points
Comment Utility
http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Q_22542230.html

I found pretty much exactly what I was looking for here, but thanks tips
0
 

Author Closing Comment

by:BKennedy2008
Comment Utility
found in another spot
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now