Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

creating a GUID in excel

Posted on 2012-03-22
3
Medium Priority
?
5,240 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 7

Expert Comment

by:tipsybroom
ID: 37754159
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
ID: 37754363
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
ID: 37792672
found in another spot
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

704 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