I previously used Word for Mac 2011 where I recorded the following macro to set all margins at 0.4". I tried recording the same macro on Word for Mac 2016 but the keystrokes were not recorded. I tried to copy and paste the following code into the Word for Mac 2016 VB editor, but I got a compiler error. Can you help me debug it? Thanks.
Sub Macro1() ' ' With ActiveDocument.PageSetup .LineNumbering.Active = False .TopMargin = InchesToPoints(0.4) .BottomMargin = InchesToPoints(0.4) .LeftMargin = InchesToPoints(0.4) .RightMargin = InchesToPoints(0.4) .Gutter = InchesToPoints(0) .HeaderDistance = InchesToPoints(0.5) .FooterDistance = InchesToPoints(0.5) .SectionStart = wdSectionNewPage .OddAndEvenPagesHeaderFooter = False .DifferentFirstPageHeaderFooter = False .VerticalAlignment = wdAlignVerticalTop .SuppressEndnotes = False .MirrorMargins = False End With End Sub
When I run the macro, a small window pops up that says "Compile error: Invalid or unqualified reference". When I click "OK" the code comes up and ".LineNumbering.Active =" is highlighted. If I delete the entire ".LineNumbering.Active = False" line and try again, I get the same compiler error message and now ".TopMargin =" is highlighted.
I am no expert on VBA by any stretch of the imagination, but it seems to me that the reference "ActiveDocument.PageSetup.anything" is invalid. As soon as the complier tries to reference ActiveDocument.PageSetup.whatever, it spits out the Compile error.
Since exactly this code worked fine in Word for Mac 2011, was there some change in reference syntax in Word for Mac 2016 that I don't know about? I also found it curious that I could record certain keystrokes with "Record Macro" in Word for Mac 2016 but not certain drop-down menu commands. I hope that this is not a bug in Word for Mac 2016.
Thank you for helping. My impression is that Microsoft deprecated the ability to encode drop-down menu commands into user-recorded macros in Word for Mac 2016. This would explain my inability to record page margin changes into a macro in the 2016 version and would also explain why my 2011 macro code is not getting hold of the PageSetup object in the 2016 version. Word for Mac 2016 does include a new drop-down menu option that achieves nearly the same margin adjustments, so I'll just use that one for now. You assistance is much appreciated.
I got a UserControl called "Card"; on a page I will have up to a hundred Cards, named as Card0, Card1, etc. and I cannot access their properties or controls because Findcontrol does not work for Usercontrol.
BTW, here is my code:
' the following three lines return NOTHING
Dim one_card as UserControl = FindControl("Card0")
Dim one_card as Card = FindControl("Card0")
Dim one_card as Control = FindControl("Card0")
I also tried Page.Findcontrol.
What am I doing wrong? Are there any workarounds? Thanks.
For my user controls on "my machine" (er...asp.net...) yes. The questions I've asked are an attempt to drag sufficient information out of you so that someone can actually help. "Points"...it's not like I can convert those 2 rep points into cash!
As I can't tell clearly here where you are trying to call FindControl from, I would suggest that you aren't doing this from your MasterPage, so you might want to try Master.FindControl("Card0") to find this control on the master page.
I added a
DataGridViewCheckBoxColumn to My Data Grid
Dim DesChkBox AsNew DataGridViewCheckBoxColumn
DesChkBox.Name = "chbSelect"
DesChkBox.HeaderText = "Select"
DesChkBox.TrueValue = True
DesChkBox.FalseValue = False
DesChkBox.Width = 50
grdView.ReadOnly = False
grdView.AutoGenerateColumns = False
grdView.RowHeadersWidth = 5And through a procedure I want to check the Check Box programmatically.
grdView.Rows(0).Cells(3).Value = TrueCatch ex As Exception
The Check Box isnot Checking. Please help me.