打开文件时如何修复activeX复选框移动 [英] How to fix activeX checkboxes moving when opening file

查看:45
本文介绍了打开文件时如何修复activeX复选框移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道以前有人问过这个问题,但我没有找到合适的答案.我无法进行 Windows 更新,因为此表单已在全国多台计算机上使用.

I know this question have been ask before but I did not find a good answer for me. I can't do the windows updates because this form is used on multiple computers all across the country.

我有 24 个默认隐藏的复选框,它们根据组合框的值变为可见.如果我保存带有隐藏复选框的文件,一旦我打开它,所有复选框都将位于一个位置(而不是它们应该在的位置).如果我在复选框可见的情况下保存它,那么我打开它一切正常.

I have 24 checkboxes that are hidden by default and them become visible depending on the combobox value. If I save the file with the checkboxes being hidden, once I open it all the checkboxes will be at one spot(not where they are suppose to be). If I save it with the checkboxes being visible then I open it everything work perfectly fine.

这很糟糕这是一个很好的

This is the bad one This is the good one

我让它工作的唯一方法是,如果我在隐藏所有复选框的情况下保存它,然后在工作簿打开时隐藏它们.如果用户没有正确保存它,这可能是一个问题.像这样

The only way that I got it to work is if I save it with all the checkboxes being hidden then I hide them when workbook is open. This could be a problem if the user does not save it properly. Like this

 'if the row the row is hidden then the 2 checkboxes on this row are hidden too
 ActiveSheet.Rows("54:101").Hidden = False

 'Hide rows 54 to 101
 ActiveSheet.ComboBox2.Value = ""
 ActiveSheet.ComboBox3.Value = ""

我尝试更改复选框的对象定位属性,但似乎必须是 Move but don't size with cells 才能使其工作

I tried changing the object positioning property of the checkboxes but it seems like it has to be Move but don't size with cells for it to work

推荐答案

我自己修复了它.我的解决方案是像这样为每个复选框设置一个单元格的位置

I fixed it myself. My solution is to set a location to a cell for every checkbox like so

Dim rng As Range
Set rng = ActiveSheet.Range("H65")
With ActiveSheet.OLEObjects("CheckBox223")
    .Top = rng.Top
    .Left = rng.Left
    .Width = rng.Width
    .Height = rng.RowHeight
End With

 Set rng = ActiveSheet.Range("J65")
 With ActiveSheet.OLEObjects("CheckBox224")
    .Top = rng.Top
    .Left = rng.Left
    .Width = rng.Width
    .Height = rng.RowHeight
End With

 Set rng = ActiveSheet.Range("H69")
 With ActiveSheet.OLEObjects("CheckBox221")
    .Top = rng.Top
    .Left = rng.Left
    .Width = rng.Width
    .Height = rng.RowHeight
End With

 Set rng = ActiveSheet.Range("J69")
 With ActiveSheet.OLEObjects("CheckBox222")
    .Top = rng.Top
    .Left = rng.Left
    .Width = rng.Width
    .Height = rng.RowHeight
End With

 Set rng = ActiveSheet.Range("H73")
 With ActiveSheet.OLEObjects("CheckBox219")
    .Top = rng.Top
    .Left = rng.Left
    .Width = rng.Width
    .Height = rng.RowHeight
End With

 Set rng = ActiveSheet.Range("J73")
 With ActiveSheet.OLEObjects("CheckBox220")
    .Top = rng.Top
    .Left = rng.Left
    .Width = rng.Width
    .Height = rng.RowHeight
End With

这篇关于打开文件时如何修复activeX复选框移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆