+ Reply to Thread
Results 1 to 5 of 5

Macro Code for multi-user .xlsm document

  1. #1
    Registered User
    Join Date
    10-07-2012
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003
    Posts
    5

    Smile Macro Code for multi-user .xlsm document

    I am very new to Macros and I am trying to learn from the Internet. I have copied certain codes into a Purchase Order .xlsm document module and it is working good in the server PC. The document when accessed by the network PC's opens only as "read only" document if the master document is open in the Server PC or in other network PC's. On creating a purchase order in any of the network PC's, when the master document is open in other PC's, the completed document is saviing in the master folder of the server PC but the number is not getting updated in the master file in the server PC or in other network PC's. Can someone give a solution? Given below is the Macro Code I am using:

    Sub nextPurchaseOrder()
    Dim nextPurchaseOrder As Variant
    If Range("K3") < 1 Then 'cell in which the Amendment number is stored

    Range("Q11").Value = Range("Q11").Value + 1 'cell in which the Purchase Order number is stored

    ElseIf Range("K3") > 0 Then

    Range("Q12").Value = Range("Q12").Value + 1

    End If


    End Sub

    Sub CopyToExcel()
    Dim wbk As Workbook
    'from a workbook, multi-user compatible

    On Error Resume Next
    Set wbk = Workbooks("C:\Documents and Settings\All Users\Documents\Purchase Order\1 PO Macros Master.xlsm")
    On Error GoTo 0
    If wbk Is Nothing Then
    Workbooks.Open ("C:\Documents and Settings\All Users\Documents\Purchase Order\1 PO Macros Master.xlsm")
    Set wbk = Workbooks("C:\Documents and Settings\All Users\Documents\Purchase Order\1 PO Macros Master.xlsm")
    End If

    Application.ScreenUpdating = False
    Application.EnableEvents = False
    Application.DisplayAlerts = False

    'reopen the workbook
    Workbooks.Open Filename:= _
    "C:\Documents and Settings\All Users\Documents\Purchase Order\1 PO Macros Master.xlsm", Editable:=True

    With ActiveWorkbook.Sheets(wbk) 'update the workbook's current purchaseorder number
    NewVal = .Range("Q11").Value 'remember the new number
    End With
    ActiveWorkbook.Close True 'close the workbook, save changes

    .Range("Q11").Value = NewVal 'put new number into current sheet
    .Range("Q11") = "Incremented" 'flag the doublecheck cell
    Application.ScreenUpdating = True
    Application.EnableEvents = True
    End If
    End With

    'normal save continues from here...

    End Sub

    Sub SavePurchaseOrderWithNewName()
    Dim NewFN As Variant
    ' Copy PurchaseOrder to a new workbook
    ActiveSheet.Copy
    Range("A1:L61").Formula = Range("A1:L61").Value
    Range("A1:Q61").ClearComments
    Range("A3:B7").ClearContents
    Range("M1:MZ5000").Delete
    If Range("K3") < 1 Then
    NewFN = "C:\Documents and Settings\All Users\Documents\Purchase Order\Purchase Order - " & Range("H3").Value & ".xlsx"
    ElseIf Range("K3") > 0 Then
    NewFN = "C:\Documents and Settings\All Users\Documents\Purchase Order\Amendment -PO " & Range("H5").Value & ".xlsx"
    End If

    ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbook
    ActiveWorkbook.Close
    nextPurchaseOrder
    End Sub

  2. #2
    Forum Contributor Legend Rubber's Avatar
    Join Date
    09-21-2012
    Location
    Tillsonburg, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    392

    Re: Macro Code for multi-user .xlsm document

    Welcome to the Forum, but you should post code in CODE TAGS.
    One of the moderators will explain how better, but you simply highlight all the code, and click the # symbol.

  3. #3
    Registered User
    Join Date
    10-07-2012
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Macro Code for multi-user .xlsm document

    Thanks! Shall try to do what you said:

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    10-07-2012
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Macro Code for multi-user .xlsm document

    Hope the code sheet posted is ok for someone to help. Thanks

  5. #5
    Registered User
    Join Date
    10-07-2012
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Macro Code for multi-user .xlsm document

    I have spoken to a few friends who know macro coding and they have clarified that multi-user conditions for documents do not work in Excel. Hence I would like to close this thread as there is no solution within Excel

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1