+ Reply to Thread
Results 1 to 4 of 4

Copy data to protected workbook

  1. #1
    Registered User
    Join Date
    06-07-2010
    Location
    Blantyre, Malawi
    MS-Off Ver
    Excel 2003
    Posts
    20

    Question Copy data to protected workbook

    In order to protect my code and data I run the code (pasted below) when my programme starts. It works fine but it has caused me a separate problem.

    I have two programmes. One called VatMan (which contains the following code)
    The other is FileConvert which copies data into VatMan.

    The problem is that VatMan must be open for the FileConvert to work yet when you open VatMan it will not allow itself to be minimised so that another programme can be run.

    Do you have any idea what I can do to work around this problem?

    I have posted this problem on other pages but have had no responses yet.

    Regards,

    Alan

    CODE WITHIN VatMan

    Sub HideAllToolbars()

    Dim i As Integer
    For i = 1 To Application.Toolbars.Count
    Application.Toolbars(i).Visible = False
    Next i
    ' Turn off Toolbar List Shortcuts
    CommandBars("Toolbar List").Enabled = False
    ' Turn off right click
    CommandBars(21).Enabled = False
    ' Turn off alt F11
    Application.OnKey "%{F11}", ""

    End Sub



    CODE WITHIN FILECONVERT

    Sub CopyToVatMan()

    Dim Var1 As String ‘Used to get destination Workbook
    Dim rg1 As Range ‘Data to be copied from Conversion to VatMan
    Dim TType As String ‘Tells what Worksheet to be used in VatMan
    Dim Pg As String ‘Tells what Worksheet to be used in VatMan


    Workbooks("FileConvert.xls").Activate
    TType = Sheets("ConversionPage").Cells(2, 1)
    If TType = "EXPENSE" Then
    Pg = "Expense(Invoices Paid)"
    ElseIf TType = "INCOME" Then
    Pg = "Income(Invoices Issued)"
    ElseIf TType = "EXPORTS" Then
    Pg = "Exports"
    ElseIf TType = "CAPEX" Then
    Pg = "Capital"
    ElseIf TType = "NREXPENSE" Then
    Pg = "NonRegistered"
    Else
    MsgBox "There is a problem with your data. Please talk to your IT department before continuing"
    GoTo xx
    End If

    FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
    FinalCol = Cells(1, Columns.Count).End(xlToLeft).Column
    On Error GoTo FileMissing
    ‘Following line allows user to select name of current VatMan destination file
    Var1 = Application.InputBox(prompt:="Enter the name and extention of the VatMan file you wish to update. (e.g. VatManFeb.xls)", Type:=2)
    Sheets("ConversionPage").Select
    Range("A2:a2").Resize(FinalRow, FinalCol).Copy Destination:=Workbooks(Var1).Worksheets(Pg).Range("A13")
    MsgBox "Transfer Complete"

    xx:
    FileMissing:
    MsgBox "The File name entered either can not be found or has not been opened."
    End Sub

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Copy data to protected workbook

    Hi AlanAnderson

    Welcome to the Forum

    Add Code tags before the moderators get you!!...

    Forum Rules
    3. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # button at the top of the post window. If you are editing an existing post, press Go Advanced to see the # button

  3. #3
    Registered User
    Join Date
    06-07-2010
    Location
    Blantyre, Malawi
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: Copy data to protected workbook

    Hi All,
    Sorry for that. I am totally new to this.
    Hope I've done this code tagging correctly,

    Alan

    In order to protect my code and data I run the code (pasted below) when my programme starts. It works fine but it has caused me a separate problem.

    I have two programmes. One called VatMan (which contains the following code)
    The other is FileConvert which copies data into VatMan.

    The problem is that VatMan must be open for the FileConvert to work yet when you open VatMan it will not allow itself to be minimised so that another programme can be run.

    Do you have any idea what I can do to work around this problem?

    Regards,

    Alan

    CODE WITHIN VatMan

    Please Login or Register  to view this content.

    CODE WITHIN FILECONVERT

    Please Login or Register  to view this content.

  4. #4
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Copy data to protected workbook

    hmmm...........

    Have you tried simply Protecting the workbooks? Instead of trying to control the Application.

    At first sight you appear to be making problems for yourself , why do you want to disable Tollbars, etc?

    Also this code will have little effect if the workbook is opened with 2007.

    Cheers

    P.S.
    Thanks for adding code tags, but you should have added them by editing Post #1 rather than Posting (correctly) again.
    The mods don't like "clutter" either!!!

    Cheers

+ 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