+ Reply to Thread
Results 1 to 5 of 5

Is there a method by which we can programatically save the workbook?

  1. #1
    divya
    Guest

    Is there a method by which we can programatically save the workbook?

    Is there a method by which we can programatically save the workbook?
    Like workbook.close closes the workbook,I couldn't find
    workbook.save.Is there a way to do.
    Actually therz a variable suppose y, if its 1 then next time the user
    opens the workbook therz a form which should'nt be displayed.So what I
    did is copied the value of y into one of the worksheet and cheking
    this cell value in the workbook_open event .if not 1 then dispalys the
    form.But problem arises when user inputs Y as 1 and closes the book
    without saving.The value of y is not saved in the book,so next time
    form opens when he opens the workbook.
    My problem can be solved either of two cases

    1.therz a way to force the workbook to save immediately after taking
    the input value for y,programatically.
    2.A way to find that workbook is opened for the first time.

    Kindly suggest a way

    Regards


  2. #2
    NickHK
    Guest

    Re: Is there a method by which we can programatically save the workbook?

    Perhaps in the Workbook_BeforeClose event
    If Thisworkbook.Saved=False Then ThisWorkbook.Save True

    Not sure what you mean aboyt the Y/1 issue, but in the Workbook_Open you
    can:
    ThisWorkbook.Range("Counter").Value=ThisWorkbook.Range("Counter").Value+1

    NickHK

    "divya" <divya_sanam@yahoo.com> wrote in message
    news:1152698689.551441.137930@i42g2000cwa.googlegroups.com...
    > Is there a method by which we can programatically save the workbook?
    > Like workbook.close closes the workbook,I couldn't find
    > workbook.save.Is there a way to do.
    > Actually therz a variable suppose y, if its 1 then next time the user
    > opens the workbook therz a form which should'nt be displayed.So what I
    > did is copied the value of y into one of the worksheet and cheking
    > this cell value in the workbook_open event .if not 1 then dispalys the
    > form.But problem arises when user inputs Y as 1 and closes the book
    > without saving.The value of y is not saved in the book,so next time
    > form opens when he opens the workbook.
    > My problem can be solved either of two cases
    >
    > 1.therz a way to force the workbook to save immediately after taking
    > the input value for y,programatically.
    > 2.A way to find that workbook is opened for the first time.
    >
    > Kindly suggest a way
    >
    > Regards
    >




  3. #3
    divya
    Guest

    Re: Is there a method by which we can programatically save the workbook?

    I thought there is no command called workbook.save,Actually there is
    ,Activeworkbook.save works.My problem is sorted
    Thnks for ure suggestion Nick



    NickHK wrote:
    > Perhaps in the Workbook_BeforeClose event
    > If Thisworkbook.Saved=False Then ThisWorkbook.Save True
    >
    > Not sure what you mean aboyt the Y/1 issue, but in the Workbook_Open you
    > can:
    > ThisWorkbook.Range("Counter").Value=ThisWorkbook.Range("Counter").Value+1
    >
    > NickHK
    >
    > "divya" <divya_sanam@yahoo.com> wrote in message
    > news:1152698689.551441.137930@i42g2000cwa.googlegroups.com...
    > > Is there a method by which we can programatically save the workbook?
    > > Like workbook.close closes the workbook,I couldn't find
    > > workbook.save.Is there a way to do.
    > > Actually therz a variable suppose y, if its 1 then next time the user
    > > opens the workbook therz a form which should'nt be displayed.So what I
    > > did is copied the value of y into one of the worksheet and cheking
    > > this cell value in the workbook_open event .if not 1 then dispalys the
    > > form.But problem arises when user inputs Y as 1 and closes the book
    > > without saving.The value of y is not saved in the book,so next time
    > > form opens when he opens the workbook.
    > > My problem can be solved either of two cases
    > >
    > > 1.therz a way to force the workbook to save immediately after taking
    > > the input value for y,programatically.
    > > 2.A way to find that workbook is opened for the first time.
    > >
    > > Kindly suggest a way
    > >
    > > Regards
    > >



  4. #4
    halim
    Guest

    Re: Is there a method by which we can programatically save the workbook?

    Dear Divia,

    Why you don't use MSReg commands like :

    Private Sub Workbook_Open()
    Dim Opn1sttime As Integer, r As Long
    On Error GoTo er
    r = GetSetting("AppName", "SectName", "KeyName") + 1
    er:
    SaveSetting "AppName", "SectName", "KeyName", r
    Y = r
    MsgBox Y
    End Sub

    Try it...

    Halim


    divya menuliskan:
    > Is there a method by which we can programatically save the workbook?
    > Like workbook.close closes the workbook,I couldn't find
    > workbook.save.Is there a way to do.
    > Actually therz a variable suppose y, if its 1 then next time the user
    > opens the workbook therz a form which should'nt be displayed.So what I
    > did is copied the value of y into one of the worksheet and cheking
    > this cell value in the workbook_open event .if not 1 then dispalys the
    > form.But problem arises when user inputs Y as 1 and closes the book
    > without saving.The value of y is not saved in the book,so next time
    > form opens when he opens the workbook.
    > My problem can be solved either of two cases
    >
    > 1.therz a way to force the workbook to save immediately after taking
    > the input value for y,programatically.
    > 2.A way to find that workbook is opened for the first time.
    >
    > Kindly suggest a way
    >
    > Regards



  5. #5
    halim
    Guest

    Re: Is there a method by which we can programatically save the workbook?

    Dear Divia .... ... Again! )))

    Private Sub Workbook_Open()
    Dim Opn1sttime As Integer, r As Long

    On Error GoTo er 'for 1st time if we never savesetting, to handle
    error!
    r = GetSetting("AppName", "SectName", "KeyName") + 1
    er:
    if r = 0 then r = 1 'Assign open first time as 1 (first)SaveSetting
    "AppName", "SectName", "KeyName", r
    Opn1sttime = r
    if Opn1sttime > 1 then
    ThisWorkbook.Close True
    Else: UserForm!.Show
    Endif
    'MsgBox Opn1sttime ' Opn1sttime = Y , you mean Divia !
    End Sub
    'that saved in MS registry :
    'HKEY_CURRENT_USER\Software\VB and VBA Program Settings


    Regards,,

    Halim Chan


    divya menuliskan:
    > I thought there is no command called workbook.save,Actually there is
    > ,Activeworkbook.save works.My problem is sorted
    > Thnks for ure suggestion Nick
    >
    >



    > > > Is there a method by which we can programatically save the workbook?
    > > > Like workbook.close closes the workbook,I couldn't find
    > > > workbook.save.Is there a way to do.
    > > > Actually therz a variable suppose y, if its 1 then next time the user
    > > > opens the workbook therz a form which should'nt be displayed.So what I


    > > > 1.therz a way to force the workbook to save immediately after taking
    > > > the input value for y,programatically.
    > > > 2.A way to find that workbook is opened for the first time.



+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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